Repository navigation
fix: avoid unhandled rejection when DeferrableMap.getDeferred is aborted - #2156
Open
Abhishek-B-R wants to merge 1 commit into
Open
Abhishek-B-R wants to merge 1 commit into
Abhishek-B-R wants to merge 1 commit into
Conversation
Abhishek-B-R
requested review from
1egoman,
lukasIO and
xianshijing-lk
as code owners
October 17, 2026 09:35
🦋 Changeset detectedLatest commit: 91385fc The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
|
1egoman
approved these changes
Oct 18, 2026
1egoman
left a comment
Contributor
There was a problem hiding this comment.
This looks great to me, great catch and thank you for the contribution.
@Abhishek-B-R Would you be able to click the "CLA not signed yet" button and sign the CLA? Once you do this I'll merge.
This branch has not been deployed
This file contains hidden or 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
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.
Summary
DeferrableMap.getDeferred(key, signal)(exposed asremoteParticipant.dataTracks.getDeferred()) removes its abort listener withfuture.promise.finally(...)..finally()returns a new promise that re-rejects with the same reason, and nothing handles that one. So when the signal aborts, the caller gets theAbortErroron the promise it awaited, and a second copy of the same error is reported as an unhandled rejection. Wrapping the call intry/catchdoesn't help, so apps that cancel a wait for a data track see "Uncaught (in promise) AbortError" in the console, and error trackers that listen forunhandledrejectionrecord it.Changes
.then(cleanup, cleanup)instead of.finally(cleanup), so the internal chain handles both outcomes. The promise returned to the caller is unchanged and still rejects withDeferrableMapAbortError.src/utils/deferrable-map.test.ts(there was no test file forDeferrableMap): existing key, resolve onset, already aborted signal, and abort while pending.Testing
The abort test catches the rejection, waits one macrotask, then checks
process.on('unhandledRejection')saw nothing. On main it fails with one unhandledAbortError(reason'gave up'); with the fix all 4 tests pass.pnpm testpasses (57 files, 977 tests), andtsc --noEmit, eslint and prettier are clean.