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

[event-hubs] EventHubProducerClient.sendBatch can throw TypeError "Cannot read property 'credit' of undefined" #15002

Closed
chradek opened this issue Apr 23, 2021 · 0 comments · Fixed by #15021
Assignees
Labels
bug This issue requires a change to an existing behavior in the product in order to be resolved. Client This issue points to a problem in the data-plane of the library. Event Hubs
Milestone

Comments

@chradek
Copy link
Contributor

chradek commented Apr 23, 2021

Description

The EventHubProducerClient.sendBatch() method can throw an unexpected TypeError: "Cannot read property 'credit' of undefined" if both

  1. a connection disconnect occurs after the sender link has been initialized and
  2. one of the send attempts fails with a retryable error, the connection is disconnected, and retries have not been exhausted.

Which versions of @azure/event-hubs are impacted?

This bug was introduced in PR #13826 which was published in version 5.5.0 of event hubs.

Root cause analyses

PR #13826 separated the sendEventPromise logic so that sender initialization occurs separately from sending the message. This means if the sending of the message fails, it does not check if the sender link exists before attempting to send the message.

When a connection disconnected event is encountered, all links are closed, which removes the reference to the old sender the EventHubSender held a reference to.

So for this to occur, the connection needs to encounter a disconnected event between the time it takes to initialize a sender link, and the time it takes to successfully send an event to the service.

Potential fix

We can move the sender initialization logic into the same retried operation as sending the link. In addition, we should remove our non-null assertions so we're properly handling cases where sender may be null.

Discovery

This showed up in one of our internal scheduled CI live test runs. It has only appeared once over the last 30 days.

@chradek chradek added bug This issue requires a change to an existing behavior in the product in order to be resolved. Client This issue points to a problem in the data-plane of the library. Event Hubs labels Apr 23, 2021
@chradek chradek self-assigned this Apr 23, 2021
@ramya-rao-a ramya-rao-a added this to the [2021] May milestone Apr 24, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Apr 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue requires a change to an existing behavior in the product in order to be resolved. Client This issue points to a problem in the data-plane of the library. Event Hubs
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants