Skip to content
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

Pipeline error source #34873

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/internal/streams/pipeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ function pipeline(...streams) {

if (err && (!error || error.code === 'ERR_STREAM_PREMATURE_CLOSE')) {
error = err;
error.index = this.index;
}

if (!error && !final) {
Expand All @@ -181,6 +182,8 @@ function pipeline(...streams) {
const reading = i < streams.length - 1;
const writing = i > 0;

finish.bind({ index: i });
Copy link
Contributor

@aduh95 aduh95 Aug 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function.prototype.bind doesn't modify the original finish function, so that line has no effect as is. You would need to do something like:

const finishWithIndex = finish.bind({ index: i });

// ... and below, change occurrences of `finish` in the function scope
destroys.push(destroyer(ret, false, true, finishWithIndex));

Not a very elegant variable name, I'm very bad at naming those things 😅


if (isStream(stream)) {
finishCount++;
destroys.push(destroyer(stream, reading, writing, finish));
Expand Down