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.
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