Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
ronag committed Nov 19, 2021
1 parent 6fbe14d commit 6d65966
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 18 deletions.
4 changes: 2 additions & 2 deletions lib/internal/streams/destroy.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,12 +326,12 @@ function emitErrorCloseLegacy(stream, err) {
}

// Normalize destroy for legacy.
function destroyer(stream, err) {
function destroyer(stream, err, options) {
if (!stream || isDestroyed(stream)) {
return;
}

if (!err && !isFinished(stream)) {
if (!err && !isFinished(stream) && options?.autoAbort !== false) {
err = new AbortError();
}

Expand Down
4 changes: 3 additions & 1 deletion lib/internal/streams/readable.js
Original file line number Diff line number Diff line change
Expand Up @@ -1150,7 +1150,9 @@ async function* createAsyncIterator(stream, options) {
(error || options?.destroyOnReturn !== false) &&
(error === undefined || stream._readableState.autoDestroy)
) {
destroyImpl.destroyer(stream, null);
destroyImpl.destroyer(stream, null, {
autoAbort: false
});
}
}
}
Expand Down
30 changes: 15 additions & 15 deletions test/parallel/test-stream-pipeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -764,21 +764,21 @@ const tsp = require('timers/promises');
}));
}

// {
// const s = new PassThrough();
// pipeline(async function*() {
// await Promise.resolve();
// yield 'hello';
// yield 'world';
// }, s, async function(source) {
// for await (const chunk of source) {
// throw new Error('kaboom');
// }
// }, common.mustCall((err, val) => {
// assert.strictEqual(err.message, 'kaboom');
// assert.strictEqual(s.destroyed, true);
// }));
// }
{
const s = new PassThrough();
pipeline(async function*() {
await Promise.resolve();
yield 'hello';
yield 'world';
}, s, async function(source) {
for await (const chunk of source) {
throw new Error('kaboom');
}
}, common.mustCall((err, val) => {
assert.strictEqual(err.message, 'kaboom');
assert.strictEqual(s.destroyed, true);
}));
}

{
const s = new PassThrough();
Expand Down

0 comments on commit 6d65966

Please sign in to comment.