js-libp2p: WebRTCTransport.dial AbortError
-
Version:
-
libp2p v1.9.1
-
Platform:
-
Linux hp-elitedesk01 5.15.0-91-generic #101~20.04.1-Ubuntu SMP Thu Nov 16 14:22:28 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
-
Subsystem:
-
WebRTC
Severity:
- Critical - System crash, application panic.
Description:
I had filed this previous issue about issues I was having with the @libp2p/webrtc package. That was resolved and the current package versions can be seen here and the code for initializing libp2p can be found here.
I’m now encountering what appears to be a race condition inside the webRTC libraries. The node will run for a while and then randomly will crash with the following error message:
file:///home/safeuser/ipfs-service-provider/node_modules/race-signal/dist/src/index.js:22
return Promise.reject(new AbortError(opts?.errorMessage, opts?.errorCode, opts?.errorName));
^
AbortError: The operation was aborted
at raceSignal (file:///home/safeuser/ipfs-bch-wallet-service/node_modules/race-signal/dist/src/index.js:22:31)
at YamuxStream.closeWrite (file:///home/safeuser/ipfs-bch-wallet-service/node_modules/@libp2p/utils/dist/src/abstract-stream.js:230:19)
at YamuxStream.close (file:///home/safeuser/ipfs-bch-wallet-service/node_modules/@libp2p/utils/dist/src/abstract-stream.js:189:18)
at file:///home/safeuser/ipfs-bch-wallet-service/node_modules/libp2p/dist/src/connection/index.js:118:63
at Array.map (<anonymous>)
at ConnectionImpl.close (file:///home/safeuser/ipfs-bch-wallet-service/node_modules/libp2p/dist/src/connection/index.js:118:44)
at initiateConnection (file:///home/safeuser/ipfs-bch-wallet-service/node_modules/@libp2p/webrtc/dist/src/private-to-private/initiate-connection.js:146:34)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async WebRTCTransport.dial (file:///home/safeuser/ipfs-bch-wallet-service/node_modules/@libp2p/webrtc/dist/src/private-to-private/transport.js:93:65)
at async DefaultTransportManager.dial (file:///home/safeuser/ipfs-bch-wallet-service/node_modules/libp2p/dist/src/transport-manager.js:87:20)
at async queue.add.peerId.peerId [as fn] (file:///home/safeuser/ipfs-bch-wallet-service/node_modules/libp2p/dist/src/connection-manager/dial-queue.js:168:38)
at async raceSignal (file:///home/safeuser/ipfs-bch-wallet-service/node_modules/race-signal/dist/src/index.js:28:16)
at async Job.run (file:///home/safeuser/ipfs-bch-wallet-service/node_modules/@libp2p/utils/dist/src/queue/job.js:55:28) {
type: 'aborted',
code: 'ABORT_ERR'
}
Node.js v20.17.0
Steps to reproduce the error:
The error does not occur right away. It will appear at some point within 30 minutes while the node is running. It forces the app to crash and the process manager will restart it. But then the crash will happen again within 30 minutes.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 17 (5 by maintainers)
Commits related to this issue
- deps: update libp2p/helia to v2 and v5 respectively While investigating https://github.com/libp2p/js-libp2p/issues/2702 I've had this running for almost 12 hours without a crash. The only changes I'... — committed to achingbrain/ipfs-service-provider by achingbrain 2 years ago
- deps: update libp2p/helia to v2 and v5 respectively While investigating https://github.com/libp2p/js-libp2p/issues/2702 I've had this running for almost 12 hours without a crash. The only changes I'... — committed to achingbrain/ipfs-service-provider by achingbrain 2 years ago
- fix: update race-signal (#2986) 1.1.2 fixes a potential crash so ensure we get the latest version. Fixes #2702 — committed to magnified103/js-libp2p by achingbrain 2 years ago
Ok, I think I’ve figured out what’s happening.
.closeWritemethod rejects due also using the (aborted) signalawaiting it and so 💥This should be fixed by https://github.com/achingbrain/race-signal/pull/64 released in
race-signal@1.1.2I appreciate the tip @cristianmadularu.
I ended up just disabling WebRTC in my application until this issue can be resolved. It would be great to have, but it’s not a core requirement.
Browsers can listen on circuit relay addresses where the relayed connection is established over WebSockets/WebTransport, but any incoming connections will be time/data limited so it’s only useful under certain conditions.
For two browsers to upgrade to an unlimited direct connection you need WebRTC.
@christroutner while this is not a ‘solution’ (more of a temporary workaround), you might consider an application level handler and consider not allowing the application to crash if that type of exception goes unhandled… Risky approach since there is no guarantee that the app is still in a good state… but… an ugly workaround nevertheless… until this gets fixed.
I wouldn’t mind if webRTC fails to connect, but this error causes the application to crash and exit, and there doesn’t seem to be any way to wrap it with try/catch to handle the exception.