-
Notifications
You must be signed in to change notification settings - Fork 446
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
fix: WebRTC transport unhandled promise rejection during connect #2299
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Fixes a crash in node where the abort signal passed into a WebRTC private to private dial would cause an unhandled promise rejection: ``` file:///Users/alex/Documents/Workspaces/ipfs/helia-http-gateway/node_modules/@libp2p/webrtc/dist/src/private-to-private/initiate-connection.js:42 connectedPromise.reject(new CodeError('SDP handshake aborted', 'ERR_SDP_HANDSHAKE_ABORTED')); ^ CodeError: SDP handshake aborted at EventTarget.sdpAbortedListener (file:///Users/alex/Documents/Workspaces/ipfs/helia-http-gateway/node_modules/@libp2p/webrtc/dist/src/private-to-private/initiate-connection.js:42:37) at [nodejs.internal.kHybridDispatch] (node:internal/event_target:807:20) at EventTarget.dispatchEvent (node:internal/event_target:742:26) at abortSignal (node:internal/abort_controller:369:10) at AbortController.abort (node:internal/abort_controller:391:5) at EventTarget.onAbort (file:///Users/alex/Documents/Workspaces/ipfs/helia-http-gateway/node_modules/any-signal/dist/src/index.js:8:20) at [nodejs.internal.kHybridDispatch] (node:internal/event_target:807:20) at EventTarget.dispatchEvent (node:internal/event_target:742:26) at abortSignal (node:internal/abort_controller:369:10) at AbortController.abort (node:internal/abort_controller:391:5) { code: 'ERR_SDP_HANDSHAKE_ABORTED', props: {} } Node.js v20.8.0 ``` Simplifies the connection logic to just use the abort signal to abort the dial instead of the abort signal and multiple deferred promises.
maschad
reviewed
Dec 5, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The refactor makes sense , but are you able to simulate this race condition?
I've added a test that fails against main and also causes a
|
maschad
approved these changes
Dec 5, 2023
SgtPooki
approved these changes
Dec 5, 2023
This was referenced Dec 5, 2023
Merged
achingbrain
added a commit
that referenced
this pull request
Dec 6, 2023
We catch WebRTC errors, log them and throw normalised errors to ensure they are the same across WebRTC stacks (FF, Chrome, node). #2299 made one of these operations async which would cause an UHPR if thrown.
This was referenced Jan 18, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Simplifies the connection logic to just use the abort signal to abort the dial instead of the abort signal and multiple deferred promises.
Fixes a crash in node where the abort signal passed into a WebRTC private to private dial can cause an unhandled promise rejection due to a race condition between the abort firing and awaiting the
connectedPromise
promise:Change checklist