stream: fix unhandled rejection for errored pipeTo writes#64580
Open
dushyant-hada-90 wants to merge 1 commit into
Open
stream: fix unhandled rejection for errored pipeTo writes#64580dushyant-hada-90 wants to merge 1 commit into
dushyant-hada-90 wants to merge 1 commit into
Conversation
markPromiseAsHandled does not cancel V8's unhandled-rejection notification when the write promise is already rejected. Fall back to setPromiseHandled when the destination is no longer writable. Fixes: nodejs#64561 Refs: nodejs#63572 Signed-off-by: dushyant <dushyanthada90@gmail.com>
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.
Fixes a v26.4.0 regression where
ReadableStream.pipeTo()could crash theprocess with an unhandled rejection even when the
pipeTo()promiserejection was already caught.
In #63572, per-chunk
setPromiseHandled()was replaced withmarkPromiseAsHandled(). That is safe for pending write promises, but whena later chunk is written after the destination has already errored,
writableStreamDefaultWriterWrite()returns an already-rejected promise.Marking that promise handled afterwards does not cancel V8's pending
unhandled-rejection notification.
This keeps
markPromiseAsHandled()on the writable fast path and fallsback to
setPromiseHandled()when the destination is no longer writable(or close is queued/in flight).
No documentation changes; behavior is restored to match Node.js ≤ v26.3.1,
Deno, Bun, and browsers.
Checklist
make -j4 test(UNIX) orvcbuild test(Windows) passes / CI will validateFixes: #64561
Refs: #63572