Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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')) {
error = err;
}

Expand Down
25 changes: 25 additions & 0 deletions test/parallel/test-stream-pipeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -1749,3 +1749,28 @@ 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.
async function run() {
await assert.rejects(
pipelinep(
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
pipelinep(
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!');
}),
),
{ message: 'Boom!' },
);
}

run().then(common.mustCall());
}
Loading