-
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
[Service Bus] Reject batch receive when connection fails #6338
Conversation
A little background: Proposal: cc: @chradek |
* @param {AmqpError | Error} [receiverError] The receiver error if any. | ||
* @returns {Promise<void>} Promise<void>. | ||
*/ | ||
async onDetached(receiverError?: AmqpError | Error): Promise<void> { | ||
// Clears the token renewal timer. Closes the link and its session if they are open. | ||
if (this._newMessageReceivedTimer) { |
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.
Is there any chance that the following could occur:
- User calls receive and receives events.
- User calls receive again.
- onDetached from 1st receive call is fired. Clears timeouts and rejects promise for 2nd receive call (due to using instance references).
- 2nd receive call erroneously rejects.
My intuition is that if onDetached
is called, it's going to impact all the receive calls that are in flight (do we allow calling receive concurrently? I'm assuming we don't since we have isReceivingMessages) so the behaviour would be fine, but I wanted to make sure it was thought about.
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.
receiveMessages
cannot be called concurrently, so there will be only 1 receive operation on the batching receiver in progress at any time.
I worry that there are a few more corner cases like these and so wanted to open a conversation via the draft PR.
My initial instinct was to use an indicator on the connection of whether it is open or not and use that to reject the promise from inside of the finalAction()
But, unfortunately, rhea's isOpen()
on link, session and connection level all return true in this case. More investigation is needed
@ramya0820 I want to consider adding another timer in the finalAction() as a last resort if we don't find a better way to detect when there is an error at AMQP connection level |
Closing in favor of #6601 |
This PR updates the
onDetached
method to reject the promise returned by the ongoing receive operation to fix bug #6065When there is a connection level error, no error events are raised on the AMQP link or session level.
Therefore, an ongoing batch receive request is unaware of such errors.
Previously, there was code put in place to hold such errors in the
detachedError
variable which was then checked to decide whether the promise should be rejected or not. This worked as long as the connection error happened before thefinalAction()
on the batch receiver was called.In #6065, what is happening is that the connection is lost and credits need to be drained. We never get the drain completed event and therefore the promise never gets resolved.