Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Service Bus] Update to use latest core-amqp #6861

Merged
merged 12 commits into from
Jan 15, 2020

Conversation

ramya0820
Copy link
Member

For more context refer to #5127

Copy link
Contributor

@ramya-rao-a ramya-rao-a left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test code needs to be updated to use code instead of name on the MessagingError when checking the error types.

See the changes made to the Event Hubs library in #6673 for reference.

@@ -92,7 +92,7 @@ export class BatchingReceiver extends MessageReceiver {
const sessionError = context.session && context.session.error;
let error = new MessagingError("An error occurred while receiving messages.");
if (sessionError) {
error = translate(sessionError);
error = translate(sessionError) as MessagingError;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Casting this way is useful if down the line we want to access properties on the error object that we know are available only on the MessagingError and not Error.

But the case here is not so. We are adding this cast as a means to get away from the error TS gives that Error | MessagingError is not assignable to MessagingError.

The right approach here would be to type the error object during declaration as Error | MessagingError.

Same applies to a few other cases in this PR.

cc @chradek for any additional thoughts here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All changes here are because we want to access code and retryable properties which appear on MessagingError, so the reasoning seems fair.
The typing union would't work because the properties are not common to both (iirc while working on this locally).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that it's more correct for error should be declared as Error | MessagingError since that's what translate will actually return.

Related to that somewhat, you could also instantiate the default MessagingError later on if the error doesn't exist to avoid creating an error that will likely not be used (I'm assuming the sessionError will be available more often than not in the onSessionError handler).

Copy link
Contributor

@chradek chradek Jan 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ramya0820 Sorry, when I wrote my response your comment wasn't showing yet.

It doesn't look like either code or retryable are used in the onSessionError handler, so there's no need to cast to MessagingError inside the handler.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on local - in general declaring type as Error | MessagingError wouldn't suffice, and we'll still need the as MessagingError casting to work with TypeScript and current code.

Only changes to be updated seems to be the 2 declarations in this file - all other places we access code and/or retryable properties and require casting.

About setting default error instance later - agree, updated

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I had noticed that about these 2 instances - I meant in general all of the changes in this PR were for accessing the properties, so agree with updates to these 2 instances to be more focused on getting around TypeScript only~

Copy link
Member Author

@ramya0820 ramya0820 Jan 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although, would be have been nicer if we didn't have to require the casting to access the properties if possible. Was there a reason why Error had to be a possible return value?
(Looks like the docs may need to be updated on the utility as well - I mean on the translate utility in @azure/core-amqp)

Copy link
Contributor

@ramya-rao-a ramya-rao-a Jan 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was there a reason why Error had to be a possible return value?

Yes, the PR #6673 has all the relevant discussions around the changes to the MessagingError class as well as for the translate() function.

Looks like the docs may need to be updated on the utility as well - I mean on the translate utility in @azure/core-amqp

They were updated as part of #6673 already to the below:

Translates the AQMP error received at the protocol layer or a SystemError into a MessagingError. All other errors are returned unaltered.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it.
About the docs, I was looking at the line below that

* @returns {MessagingError} MessagingError object.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, that's a good catch. Please feel free to send a PR to update the return section of the docs in the master branch.

@ramya-rao-a
Copy link
Contributor

/azp run js - servicebus - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@ramya-rao-a
Copy link
Contributor

ramya-rao-a commented Jan 14, 2020

The feature/service-bus-track-2 branch has been updated with the latest from master and therefore should have fixes for all the different live test failures we have seen.

Please wait until the live/integration test run triggered from this PR to complete before merging this PR.

Copy link
Contributor

@ramya-rao-a ramya-rao-a left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a total of 9 live test failures. Please take a look and address them.

  • 7 test failures are regarding unexpected error name. These were found in Event Hubs as well. The errors in these test cases are expected to be different in node vs browser. The test cases need to be updated appropriately. You can refer to the corresponding test cases in Event Hubs for reference.
  • 2 are regarding the createQueue() operation.

@Azure Azure deleted a comment from azure-pipelines bot Jan 14, 2020
@ramya0820
Copy link
Member Author

/azp run js - servicebus - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@ramya0820
Copy link
Member Author

/azp run js - servicebus - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@ramya-rao-a ramya-rao-a merged commit b04922a into Azure:feature/service-bus-track-2 Jan 15, 2020
HarshaNalluru added a commit that referenced this pull request Feb 12, 2020
* Pin core-amqp version to preview.1

* Update lock file

* Fix merge conflicts

* [Service Bus] Update to use core-amqp (#5324)

* Use core-amqp in atom management client, comment tests that use token provider

* [Service Bus] Update to use latest core-amqp (#6861)

* [Service Bus] Update constructors to add overloads and use Azure Identity (#5436)

* sync-versions: rhea-promise and @azure/core-amqp for service-bus

* resolve merge conflicts appropriately

* API Report File for "@Azure/service-bus"

* Address feedback

* SERVICEBUS_CONNECTION_STRING_BROWSER remove from karma.conf

* update pnpm-lock file

* update API Report File for "@Azure/service-bus"

* remove rhea and rhea-promise dependencies

* add "rhea-promise" back

Co-authored-by: Ramya Rao <ramya.rao.a@outlook.com>
Co-authored-by: ramya0820 <45977823+ramya0820@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants