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: memory leak in connected clients counter #979

Merged
merged 2 commits into from
Aug 28, 2024

Conversation

uladzimir-danko
Copy link
Contributor

@uladzimir-danko uladzimir-danko commented Aug 25, 2024

This pr is related to the #928
The made fix didn't decrease connectedClients counter, which lead to incorrect amount of clients provided by broker.

One more issue is related to constant increase of subscriptions. My broker has a lot of unique clients per day with short keepAliveTimeout and frequent reconnection and subscription rate. I suspect that the problem is in the authorizeSubscribe method which can be async. This may lead to subscription for closed clients. In this case broker will never unsub them.

Unfortunately, I am limited in experiments on production to prove my idea, but the proposed fix seems reasonable and harmless to me.

delete that.clients[clientId]
that.deleteClient(clientId)
Copy link
Member

Choose a reason for hiding this comment

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

I think the leak was here, we were not decresing clients counter

@robertsLando robertsLando changed the title Fix memory leak fix: memory leak in connected clients counter Aug 28, 2024
@coveralls
Copy link

Pull Request Test Coverage Report for Build 10548488946

Details

  • 6 of 7 (85.71%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.2%) to 99.575%

Changes Missing Coverage Covered Lines Changed/Added Lines %
lib/handlers/subscribe.js 1 2 50.0%
Totals Coverage Status
Change from base Build 9447929816: -0.2%
Covered Lines: 827
Relevant Lines: 828

💛 - Coveralls

@robertsLando robertsLando merged commit 9b9d524 into moscajs:main Aug 28, 2024
14 checks passed
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.

3 participants