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

'disconnect' causes errors on old streams, memory leak? #43

Open
sbull opened this issue Apr 18, 2015 · 2 comments
Open

'disconnect' causes errors on old streams, memory leak? #43

sbull opened this issue Apr 18, 2015 · 2 comments

Comments

@sbull
Copy link

sbull commented Apr 18, 2015

I'm noticing that when a client disconnects, an error event gets emitted on my server's socket.io-stream even though the server stream has already received an 'end' event. I would have expected that the 'end' event would exclude any further events from happening on my server read stream (except maybe 'close'), and that the stream would be cleaned up. Specifically, I would expect Socket.prototype._onend to do something like stream.destroy() or socket.cleanup(id) to the readable end of my stream.

I might be overlooking something, but isn't this a memory leak? How should I close down my streams, if receiving the 'end' event on them doesn't do the job? Should I manually be calling destroy() on an 'end' handler?

The symptom of this problem is that my server-side readable socket.io-stream receives the commands in Socket.prototype._ondisconnect even after it has "ended", particularly the stream.emit('error', new Error('Connection aborted'));. I wouldn't expect stream that I've already consumed to give me some error event a some future time, just because the client eventually disconnects.

Am I missing something? Thanks.

@sbull
Copy link
Author

sbull commented Apr 18, 2015

Hmmmm... I'm not sure whose problem this is. It turns out that in my situation, I hadn't actually turned the stream into flowing mode yet, and never got the 'end' event (although I saw it emitted in the debug logs for socket.io:socket and socket.io-stream:socket). So apparently the stream doesn't get cleaned up from the socket unless you've consumed it, and it will throw this error event on disconnect even if it has already received the end event. :(

@nkzawa
Copy link
Owner

nkzawa commented Apr 21, 2015

Can you provide a simple snippet to reproduce the issue if possible?

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

No branches or pull requests

2 participants