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

fix(socket.io): prevent multiple listeners for same socket on disconn… #12188

Closed

Conversation

lponciolo
Copy link

@lponciolo lponciolo commented Aug 3, 2023

…ect event

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

Fixed the issue of creating multiple listeners for the 'disconnect' event. Implemented a Map to store disconnect$ Observables for each socket. If disconnect$ is not available for the socket, a new Observable is created and stored.

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behavior?

Previously, the io-adapter was creating multiple listeners for the 'disconnect' event, which was causing memory leaks.

Issue Number: 7249

What is the new behavior?

Now, the io-adapter creates only one listener for the 'disconnect' event, thereby eliminating the memory leaks.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@coveralls
Copy link

Pull Request Test Coverage Report for Build cc9c3b19-08e3-4652-aaf6-045ec10f4668

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 92.747%

Totals Coverage Status
Change from base Build 6777f298-b44f-4199-8bc0-18ada299ff35: 0.0%
Covered Lines: 6394
Relevant Lines: 6894

💛 - Coveralls

let disconnect$ = this.disconnectFunctions.get(socket);
if (!disconnect$) {
disconnect$ = fromEvent(socket, DISCONNECT_EVENT).pipe(share(), first());
this.disconnectFunctions.set(socket, disconnect$);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where do you remove items from this collection?

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

Successfully merging this pull request may close these issues.

None yet

3 participants