-
Notifications
You must be signed in to change notification settings - Fork 93
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
notificationClient: Establish ws connection only on client render #1460
Conversation
The current websocket configuration, creates a new websocket client, for every SSR generated page. Since those clients are technically active, they are never cleaned up, thus resulting in memory leak. This change makes it so, a new web socket connection is created only on first render of the component. Tests: 1. Start visiting different pages randomly 2. Observe the current websocket clients, in the Socket object. They can be found in Socket.adapters.sids 3. The size of sids should remain 1, per browser window
✅ Tests will run for this PR. Once they succeed it can be merged. |
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 thought there was no problem here, but I was wrong...
It reproduces when you start clicking on multiple pages.
This actually fixes the issue #1454. I've tested it.
can we also make sure that connections are kept open only if you have the window focused? This means unless podkrepi.bg is opened in a non-minimized browser window, there should be no socket connection open. You can check this. What I am suggesting is to open and close socket connections based on the |
ad326ae
to
415d5af
Compare
Done I think. |
Let's flip the switch in another PR |
Great work on this! This should help a lot with the resource usage for those websockets 🚀 |
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.
great work for protecting from excessive connections!!!
Closes #1454
Motivation and context
The current websocket configuration, creates a new websocket client, for every SSR generated page. Since those clients are technically active, they are never cleaned up, thus resulting in memory leak. This change makes it so, a new web socket connection is created only on first render of the component.
Testing
Steps to test