stream: prevent pipeline() callback after sync throw - #65165
Open
pacocartones wants to merge 1 commit into
Open
Conversation
Collaborator
|
Review requested:
|
When a stage in the middle of pipeline() throws synchronously (e.g. an invalid return value), the stages already wired have already incremented finishCount. When those stages later complete, their finish callbacks invoke the completion callback with no error β double-reporting the failure that the caller already received as an exception. Track synchronous throws while wiring, destroy the stages wired so far, and skip the completion callback in that case. Fixes: nodejs#65127 Signed-off-by: pacocartones <pacocartones@users.noreply.github.com>
pacocartones
force-pushed
the
fix/pipeline-sync-throw-double-report
branch
from
August 9, 2026 17:17
88532ab to
4c49ce4
Compare
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: #65127
Summary
When
pipeline()throws synchronously while wiring streams together β forexample, when a middle stage returns an invalid value (
ERR_INVALID_RETURN_VALUE)β the stages already wired have already incremented
finishCount. When thosestages complete afterwards, their finish callbacks invoke the completion
callback with no error, double-reporting the failure that the caller
already received as a synchronous exception.
This change tracks synchronous throws while wiring, destroys the stages wired
so far, and skips the completion callback in that case.
Repro (issue case A)
Before:
threw: ERR_INVALID_RETURN_VALUEandcallback: NO ERROR(double report).After:
threw: ERR_INVALID_RETURN_VALUEonly; the callback is never invoked.Verification
test/parallel/test-stream-pipeline.js:common.mustNotCall()gets invoked with success),abort paths verified unchanged against the pristine implementation.
Checklist