Skip to content

avoid emitting unhandled rejections on DecompressionStream#6108

Merged
anonrig merged 1 commit intomainfrom
yagiz/fix-decompression
Feb 18, 2026
Merged

avoid emitting unhandled rejections on DecompressionStream#6108
anonrig merged 1 commit intomainfrom
yagiz/fix-decompression

Conversation

@anonrig
Copy link
Member

@anonrig anonrig commented Feb 18, 2026

Fixes #6061

DecompressionStream (and more broadly, any pipeThrough + async iteration pattern) generates spurious unhandledrejection events even when the caller properly catches errors. This was caused by three sites creating rejected promises that were never marked as handled:

(1) the pipeThrough error handler in readable.c++ unnecessarily re-wrapped rejections via js.rejectedPromise(), creating a transient unhandled promise before V8's microtask chain could adopt it — fixed by removing the redundant .then() and marking the pipe promise as handled directly;
(2) the async iterator's pushCurrent in iterator.h re-rejected in its error handler, orphaning a promise whose error was already propagated through nextImpl — fixed by swallowing the rejection with .catch_() since pushCurrent is purely bookkeeping;
(3) the async iterator's returnFunction in readable.c++ called reader->cancel() on an already-errored stream without catching the resulting rejection. Fixed by using .catch_() to swallow the expected error during teardown.

@anonrig anonrig requested a review from jasnell February 18, 2026 20:30
@anonrig anonrig requested review from a team as code owners February 18, 2026 20:30
@anonrig anonrig force-pushed the yagiz/fix-decompression branch from 85a080d to f2e4375 Compare February 18, 2026 20:46
@anonrig anonrig requested a review from jasnell February 18, 2026 20:48
@anonrig anonrig enabled auto-merge (squash) February 18, 2026 20:52
@anonrig anonrig force-pushed the yagiz/fix-decompression branch from f2e4375 to b8f3e1c Compare February 18, 2026 21:06
@codspeed-hq

This comment has been minimized.

@anonrig anonrig merged commit 0f4e6c8 into main Feb 18, 2026
22 of 23 checks passed
@anonrig anonrig deleted the yagiz/fix-decompression branch February 18, 2026 23:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DecompressionStream generates unhandled rejections

2 participants

Comments