libp2p / js-libp2p-webrtc-star

libp2p WebRTC transport that includes a discovery mechanism provided by the signalling-star
https://libp2p.io
Other
320 stars 96 forks source link

Intermittant crash #315

Closed achingbrain closed 3 years ago

achingbrain commented 3 years ago

The following error occurs intermittently on Chrome and Firefox during IPFS CI:

ipfs:   1) interface-ipfs-core tests
ipfs:        .swarm.peers
ipfs:          should list peers only once even if they have multiple addresses:
ipfs:      AggregateError: 
ipfs:     Error: peer is not available
ipfs:         at Socket.<anonymous> (file:///home/travis/build/ipfs/js-ipfs/node_modules/libp2p-webrtc-star/src/index.js:175:67)
ipfs:         at Socket.Emitter.emit (file:///home/travis/build/ipfs/js-ipfs/node_modules/component-emitter/index.js:145:20)
ipfs:         at Socket.emitEvent (file:///home/travis/build/ipfs/js-ipfs/node_modules/socket.io-client-next/build/socket.js:264:20)
ipfs:         at Socket.onevent (file:///home/travis/build/ipfs/js-ipfs/node_modules/socket.io-client-next/build/socket.js:251:18)
ipfs:         at Socket.onpacket (file:///home/travis/build/ipfs/js-ipfs/node_modules/socket.io-client-next/build/socket.js:215:22)
ipfs:         at Manager.Emitter.emit (file:///home/travis/build/ipfs/js-ipfs/node_modules/component-emitter/index.js:145:20)
ipfs:         at Manager.ondecoded (file:///home/travis/build/ipfs/js-ipfs/node_modules/socket.io-client-next/build/manager.js:204:15)
ipfs:         at Decoder.Emitter.emit (file:///home/travis/build/ipfs/js-ipfs/node_modules/component-emitter/index.js:145:20)
ipfs:         at Decoder.add (file:///home/travis/build/ipfs/js-ipfs/node_modules/socket.io-client-next/node_modules/socket.io-parser/dist/index.js:117:23)
ipfs:         at Manager.ondata (file:///home/travis/build/ipfs/js-ipfs/node_modules/socket.io-client-next/build/manager.js:196:22)
ipfs:       at maybeSettle (file:///home/travis/build/ipfs/js-ipfs/node_modules/p-some/index.js:31:11)
ipfs:       at file:///home/travis/build/ipfs/js-ipfs/node_modules/p-some/index.js:69:23

The test is this one and the error message seems unrelated to the test code.

hannahhoward commented 3 years ago

Hi! Want to report my findings here:

I looked closely at the test here: https://github.com/ipfs/js-ipfs/blob/49f78807d7e26483bd926b45cc7e0f797d77e41b/packages/interface-ipfs-core/src/swarm/peers.js#L109-L139

I believe our answer may live somewhere in the todo referenced in these lines: https://github.com/ipfs/js-ipfs/blob/49f78807d7e26483bd926b45cc7e0f797d77e41b/packages/interface-ipfs-core/src/swarm/peers.js#L129-L131

I also see the error in question comes from here https://github.com/libp2p/js-libp2p-webrtc-star/blob/master/src/sig-server/routes-ws/next.js#L118 and I believe our problem is as follows:

Wow that's a mouthful. I have to admit -- this test feels very weird to me in this context. If the WS-Star transport only supports one address, we shouldn't be registering multiple and hoping the test works right? Maybe we ought to do the work to track which registered addresses are on which signalling servers?