Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion lib/internal/streams/pipeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ function pipelineImpl(streams, callback, opts) {
}

function finishImpl(err, final) {
if (err && (!error || error.code === 'ERR_STREAM_PREMATURE_CLOSE')) {
if (err && (!error || error.code === 'ERR_STREAM_PREMATURE_CLOSE' || error.name === 'AbortError')) {
Copy link
Member

Choose a reason for hiding this comment

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

Note that this does result in an edge case where a stream itself raises an AbortError, although probably not the end of the world.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You mean if the user aborts a stream through AbortController and THEN another error is thrown? In that case the second error arrives and overwrites it.
It's the same for ERR_STREAM_PREMATURE_CLOSE, though.

error = err;
}

Expand Down
21 changes: 21 additions & 0 deletions test/parallel/test-stream-pipeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -1749,3 +1749,24 @@ tmpdir.refresh();
assert.deepStrictEqual(err, new Error('booom'));
}));
}

{
// Errors thrown in Readable.map inside pipeline should not be
// swallowed by AbortError when the source is an infinite stream.
pipeline(
new Readable({ read() { this.push('data'); } }),
new Transform({
readableObjectMode: true,
transform(chunk, encoding, callback) {
this.push({});
callback();
},
}),
(readable) => readable.map(async () => {
throw new Error('Boom!');
}),
common.mustCall((err) => {
assert.strictEqual(err.message, 'Boom!');
}),
);
}
Loading