js-libp2p icon indicating copy to clipboard operation
js-libp2p copied to clipboard

`notifyOnTransient` also ignore disconnection events?

Open marcus-pousette opened this issue 2 years ago • 1 comments

  • Version: 1.1.0 - 1.8.2

  • Subsystem: registrar

Severity:

Medium/low

Description:

It seems like onDisconnect events are still emitted from transient connections shutting down even if notifyOnTransient is false.

I am receiving onDisconnect events when failing to establish a WebRTC connection

Steps to reproduce the error:

The seems to be intended behaviour (judging by the code).

https://github.com/libp2p/js-libp2p/blob/f27138ca1f552c4ad3e5d325fef626ba6783f0fd/packages/libp2p/src/registrar.ts#L167

Is it possible to fetch the closing connection here and skip if transient and notifyOnTransient is false ?

Feels more intuitive that connect and disconnect events are handled in the same way.

marcus-pousette avatar Jan 21 '24 23:01 marcus-pousette

Going through some of the testing for transient connections this line

https://github.com/libp2p/js-libp2p/blob/fd4aea3efea861aa11b4b25b69c5ac8842208ab5/packages/libp2p/test/registrar/registrar.spec.ts#L224

does not seem to have an effect of the outcome of the test.

If we would want to know whether a closing connection is transient or not the "peer:disconnect" info also needs to emit this

https://github.com/libp2p/js-libp2p/blob/fd4aea3efea861aa11b4b25b69c5ac8842208ab5/packages/libp2p/src/connection-manager/index.ts#L474

marcus-pousette avatar Aug 02 '24 16:08 marcus-pousette