-
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] fixes sendBatch race condition causing TypeError to be thrown #15021
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
chradek
requested review from
HarshaNalluru,
ramya-rao-a and
richardpark-msft
as code owners
April 26, 2021 16:00
/azp run js - event-hubs - tests |
Azure Pipelines successfully started running 1 pipeline(s). |
ramya-rao-a
reviewed
Apr 26, 2021
/azp run js - event-hubs - tests |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run js - event-hubs - tests |
Azure Pipelines successfully started running 1 pipeline(s). |
ramya-rao-a
approved these changes
Apr 26, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #15002
Background
@azure/event-hubs
5.5.0 introduced a bug where aTypeError
could be thrown fromEventHubProducerClient.sendBatch
if the connection was disconnected between the points where the sender link was initialized and the events were sent to the service.This was because the logic to initialize the sender link and the logic to actually send events across the link were separated into separate retriable operations. When a connection
disconnected
event is encountered after the link is initialized, the existing link is closed. However, the sending of events can be retried. Since the link was closed, we'd get our version of a null pointer error when trying to interact with the link.Changes
This PR does 2 things to fix the issue and prevent future 'null pointer' exceptions.
EventHubSender._trySendBatch
method has been updated to remove all of our TypeScript non-null assertions.)
_createLinkIfNotOpen` has been updated to return the sender link that's created directly so we can be sure it exists before we try to use it.What about Service Bus?
I looked at the Service Bus code and it already keeps the link initialization and sending of events in the same retriable operation. It currently does use a non-null type assertion on the sender link, though because the link initialization and sending of events are currently combined, this should be safe for now.