[event-hubs] EventHubProducerClient.sendBatch can throw TypeError "Cannot read property 'credit' of undefined" #15002
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
Description
The EventHubProducerClient.sendBatch() method can throw an unexpected
TypeError: "Cannot read property 'credit' of undefined"
if bothsend
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
theEventHubSender
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.
The text was updated successfully, but these errors were encountered: