mkg20001 / socket.io-pull-stream

Pull Streams for socket.io
2 stars 1 forks source link

Possible event listener leak #4

Open jacobheun opened 5 years ago

jacobheun commented 5 years ago

Creating this to keep track of a potential issue, I need to look into it more to verify.

What I believe is happening is that the disconnect events aren't being cleaned up for streams. When a sink or source is created, the socket binds a 'disconnect' listener to end the stream in the event the socket disconnects. If a stream errors (not due to a disconnect) or ends successfully, the disconnect event is never removed for that stream. While we don't want to remove all disconnect listeners, we should be removing the listener for that stream.

Assuming a stable, active socket, we could end up holding onto a growing number listeners for already ended streams.

This could be contributing to https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/issues/12

Reference https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/pull/28#pullrequestreview-178869435

mkg20001 commented 5 years ago

Additionally all packets get queued up (there is no back pressure) so the whole thing just explodes when too many packets get queued up.