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

wire.destroy does not remove the peer from the swarm #7

Closed
Ayms opened this issue Oct 14, 2014 · 5 comments
Closed

wire.destroy does not remove the peer from the swarm #7

Ayms opened this issue Oct 14, 2014 · 5 comments

Comments

@Ayms
Copy link

Ayms commented Oct 14, 2014

Similar to mafintosh/utp#3

wire.destroy is calling wire.end() which will fire the finish event but the end event is never fired so wire.on('end',..) will never be called and the peer will not be removed from the swarm.

Maybe the fix is to add self.emit('end') in the function attached to the finish event

@mafintosh
Copy link
Owner

wire.destroy triggers close which results in this being run https://github.com/mafintosh/peer-wire-swarm/blob/master/index.js#L329 so it should remove the peer from the swarm

@Ayms
Copy link
Author

Ayms commented Oct 14, 2014

swarm._remove is not called, so swarm._peer[addr] is not deleted

The use case is a successful TCP connection to a peer that does not answer to the handshake and close the connection.

@mafintosh
Copy link
Owner

In that case this is a bug in peer-wire-swarm which might be missing an close handler. This line will emit end after the stream has been drained https://github.com/mafintosh/peer-wire-protocol/blob/master/index.js#L66.

Could you open an issue in peer-wire-swarm for a missing close handler?

@mafintosh
Copy link
Owner

See the core stream docs for an explanation of the .push(null) logic, http://nodejs.org/api/stream.html

@Ayms
Copy link
Author

Ayms commented Oct 14, 2014

So maybe it's a node bug, you can see whatwg/streams#13, where you can notice that the drain method is not totally clear, or other discussions I am participating to regarding node/W3C-WHATWG Streams, where some things remain unclear too.

So, until it stabilizes I am not willing to go into more details about streams and the supposed behavior of push(null), there is probably a more straight forward solution, the bug is open too in peer-wire-swarm but now what should happen between both modules is up to you, self.emit('end') in finish just works fine for now until push(null) fires end, but this is really a detail, if you call destroy you don't care about the remaining data to be drained.

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