-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[Event Hubs] Add support for token cancellation in send requests #3323
[Event Hubs] Add support for token cancellation in send requests #3323
Conversation
`address "${this.address}", cannot send the message. opreation ` + | ||
`aborted.`; | ||
log.error(desc); | ||
throw new Error(desc); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since rest of the "error" scenarios in this file are using the "reject the promise" pattern, lets do the same here instead of throwing the error.
return reject(new Error(desc))
Also, the current messaging implies that we were not able to send the message, and so it is aborted. Instead the message should be that the send operation has been cancelled by the user
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have updated this with 710ddd9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the send operation is successful, we should remove the listener that we added here, else we will soon hit the limit for the number of listeners an event can have. Can you check how the Aborter class allows us to do that?
We might need to use |
…eja/azure-sdk-for-js into send_tokenCancellation
…k-for-js into send_tokenCancellation
Allow users to cancel a send request as described in #2641 (comment) for send().
This PR uses
addEventListener
andremoveEventListener
of Aborter class.Added
onAborted
listener usingaddEventListener
method that listens aborted request and throws error when user callsaborter.abort()
. It means that at any time if user wants to cancel the send request they can create an instance of Aborter and call abort().example: