stream: preserve error over AbortError in pipeline

Signed-off-by: marcopiraccini <marco.piraccini@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/62113
Fixes: https://github.com/nodejs/node/issues/62089
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
This commit is contained in:
Marco authored and GitHub committed 2026-03-18 06:04:26 +00:00
1 parent 9fc6b64c12
commit 4d2d6de1b6
2 files changed
+22 -1

No files matched your search

+1 -1
View File
@@ -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;
}
+21
View File
@@ -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!');
}),
);
}