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

[Service Bus] Fix MaxListenersExceededWarning by avoiding adding too many listeners #11175

Merged

Conversation

HarshaNalluru
Copy link
Member

@HarshaNalluru HarshaNalluru commented Sep 10, 2020

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)

@ghost ghost added the Service Bus label Sep 10, 2020
@HarshaNalluru HarshaNalluru changed the title [Service Bus] Fix MaxListenersExceededWarning caused by avoiding adding too many listeners [Service Bus] Fix MaxListenersExceededWarning by avoiding adding too many listeners Sep 10, 2020
@HarshaNalluru
Copy link
Member Author

/azp run js - servicebus - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Member

@richardpark-msft richardpark-msft left a 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);
}
Copy link
Member

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).

Copy link
Contributor

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?

Copy link
Member Author

@HarshaNalluru HarshaNalluru Sep 10, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants