Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 03839fb

Browse filesBrowse files
marcopiracciniaduh95
authored andcommitted
stream: preserve error over AbortError in pipeline
Signed-off-by: marcopiraccini <marco.piraccini@gmail.com> PR-URL: #62113 Fixes: #62089 Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
1 parent 193d629 commit 03839fb
Copy full SHA for 03839fb

2 files changed

+22-1Lines changed: 22 additions & 1 deletion

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/internal/streams/pipeline.js‎

Copy file name to clipboardExpand all lines: lib/internal/streams/pipeline.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ function pipelineImpl(streams, callback, opts) {
227227
}
228228

229229
function finishImpl(err, final) {
230-
if (err && (!error || error.code === 'ERR_STREAM_PREMATURE_CLOSE')) {
230+
if (err && (!error || error.code === 'ERR_STREAM_PREMATURE_CLOSE' || error.name === 'AbortError')) {
231231
error = err;
232232
}
233233

Collapse file

‎test/parallel/test-stream-pipeline.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-stream-pipeline.js
+21Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1749,3 +1749,24 @@ tmpdir.refresh();
17491749
assert.deepStrictEqual(err, new Error('booom'));
17501750
}));
17511751
}
1752+
1753+
{
1754+
// Errors thrown in Readable.map inside pipeline should not be
1755+
// swallowed by AbortError when the source is an infinite stream.
1756+
pipeline(
1757+
new Readable({ read() { this.push('data'); } }),
1758+
new Transform({
1759+
readableObjectMode: true,
1760+
transform(chunk, encoding, callback) {
1761+
this.push({});
1762+
callback();
1763+
},
1764+
}),
1765+
(readable) => readable.map(async () => {
1766+
throw new Error('Boom!');
1767+
}),
1768+
common.mustCall((err) => {
1769+
assert.strictEqual(err.message, 'Boom!');
1770+
}),
1771+
);
1772+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.