-
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] Update send operation to include initialization #4319
Conversation
…perationTimeoutError
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.
@ramya0820 Am curious as to why we need 2 promises in the first place. Did you try having a single promise?
I would have imagined the older send function to include the below before attempting to send the event would have done the trick.
if (!this.isOpen()) {
await defaultLock.acquire(this.senderLock, this._init).catch(reject);
}
Agree, so I wasn't aware that converting func to
About this, the |
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.
This looks good to me, can you confirm the tests are passing?
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.
One change requested: call setTimeout before the init logic.
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.
Looking better! Left 1 comment. Please take a look at that and Chris's comments
Looks like build is failing because you removed the use of an imported method, but didn't remove the import. |
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.
Please resolve the merge conflict, trigger a round of live tests and then merge the PR
const waitTimer = setTimeout( | ||
actionAfterTimeout, | ||
getRetryAttemptTimeoutInMs(options.retryOptions) | ||
); |
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.
Due to the re-arrangement of the timer, if if (abortSignal && abortSignal.aborted)
below returns true, then we end up returning a rejected promise (which is right) without clearing the timer.
Please consider keeping the previous order of the callbacks/helper-functions and only adding the link creation part at the right place
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.
The ordering in the recent commit of eaaf17e is better, but still needs work.
In the current setup, if the abort signal is fired when the async process of init()
is in progress, then the promise is being rejected only after init()
is complete. This is because init()
is being called before the event handler for abort
event was added.
Please make the below changes
- Add the event handler for abort before calling init() and before starting the timer
- Remove the event handler for abort before rejecting the promise when
init()
fails
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.
#4322 (comment) thread specifically clarifies about abort during init().
This scenario if we want to address would then need to apply for the managementRequest as well correct? Or did we specifically exclude this because of complexity involved? (In not having access to removeListeners() on sender link from the SDK?) It just feels like UX is not consistent in both cases.
Okay to implement the optimization and new corner cases from this.
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.
This scenario applies to managementRequest as well i.e. the scenario of abort signal being fired when the async process of init() is in progress.
I have updated the comment thread for managementRequest. Please see https://github.com/Azure/azure-sdk-for-js/pull/4322/files#r305599979
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.
/azp run js - eventhubs-client - tests |
Azure Pipelines successfully started running 1 pipeline(s). |
For more context refer to #2835