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

Subscriptions are not cleaned on client disconnect #24

Closed
kpdecker opened this issue Sep 8, 2015 · 3 comments
Closed

Subscriptions are not cleaned on client disconnect #24

kpdecker opened this issue Sep 8, 2015 · 3 comments
Assignees
Labels
bug
Milestone

Comments

@kpdecker
Copy link
Contributor

@kpdecker kpdecker commented Sep 8, 2015

It does not look like subscriptions are being cleaned when the client disconnects, leaving the possibility of leaking.

With this diff, this test will now fail as the subscribers object has length of 2, maintaining a reference to the disconnected client.

diff --git a/test/client.js b/test/client.js
index a61a833..e19c6df 100755
--- a/test/client.js
+++ b/test/client.js
@@ -748,6 +748,10 @@ describe('Browser', function () {
                                     client2.disconnect();
                                     setTimeout(function () {

+                                        var listener = server.connections[0].plugins.nes._listener;
+                                        var match = listener._router.route('sub', '/');
+                                        expect(match.route.subscribers.length).to.equal(1);
+
                                         server.publish('/', 'heya');
                                     }, 10);
                                 }, 10);
@hueniverse

This comment has been minimized.

Copy link
Member

@hueniverse hueniverse commented Sep 8, 2015

Yeah, I put a temporary hack in there to drop the dead ones on publish() but it needs to move to the disconnection flow.

@hueniverse hueniverse added the bug label Sep 8, 2015
@hueniverse hueniverse self-assigned this Sep 10, 2015
@hueniverse hueniverse added this to the 0.4.0 milestone Sep 10, 2015
@hueniverse

This comment has been minimized.

Copy link
Member

@hueniverse hueniverse commented Sep 10, 2015

I've decided that it is better to keep an array of strings (socket ids) instead of having to manage the subscription lists when sockets disconnect. This way they will get cleaned at little cost on publish. I am considering adding a scheduled cleanup timer.

hueniverse added a commit that referenced this issue Sep 11, 2015
@hueniverse

This comment has been minimized.

Copy link
Member

@hueniverse hueniverse commented Sep 11, 2015

Ok. Not it's fixed properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.