-
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] Fix MaxListenersExceededWarning by avoiding adding too many listeners #11175
[Service Bus] Fix MaxListenersExceededWarning by avoiding adding too many listeners #11175
Conversation
/azp run js - servicebus - tests |
Azure Pipelines successfully started running 1 pipeline(s). |
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.
Approved with a comment that we probably want to take a look at this (and all locations) to make sure the pattern you've established is properly applied everywhere.
await this._init(sendRequestOptions?.abortSignal); | ||
if (!this.isOpen()) { | ||
await this._init(sendRequestOptions?.abortSignal); | ||
} |
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 fix should work.
I think the issue here is that the two event listeners that are being added should have been passed in as part of the respective options for their links, much like this one is for session error:
onSessionError: (context: EventContext) => { |
(and yes, I totally missed this during my refactor. We can add in some testing for this and possibly a longer term fix as a later PR).
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.
@richardpark-msft, Can you log an issue for the said longer term fix or do we want to re-use the existing one?
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.
I think the issue here is that the two event listeners that are being added should have been passed in as part of the respective options for their links, much like this one is for session error
Agree with that. I did think in those lines, though didn't spend much time on how. Moreover, initializing the link for each request shouldn't happen even if we tie the listeners and since that fixes the current issue, went ahead just with it.
Issue #11154
Cause
The listeners for sender_error, receiver_error were added when the management link is initialized.
managementClient._init
is being called for each of the management requests irrespective of the link being active/inactive.As a result, listeners are being added for each request without cleaning up the older ones and hence blowing up the max limit (10).
Fix
The fix in this PR is to call the _init only if the link is not open. This prevents from adding too many listeners.
(This I feel is the missing part from the refactoring at #10807)