mirror of
https://github.com/nodejs/node.git
synced 2026-11-29 14:27:57 -05:00
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:
1 parent
9fc6b64c12
commit
4d2d6de1b6
2 files changed
+22
-1
No files matched your search
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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!');
|
||||
}),
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user