Skip to content

Commit 6d65966

Browse files
committed
fixup
1 parent 6fbe14d commit 6d65966

File tree

3 files changed

+20
-18
lines changed

3 files changed

+20
-18
lines changed

lib/internal/streams/destroy.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,12 +326,12 @@ function emitErrorCloseLegacy(stream, err) {
326326
}
327327

328328
// Normalize destroy for legacy.
329-
function destroyer(stream, err) {
329+
function destroyer(stream, err, options) {
330330
if (!stream || isDestroyed(stream)) {
331331
return;
332332
}
333333

334-
if (!err && !isFinished(stream)) {
334+
if (!err && !isFinished(stream) && options?.autoAbort !== false) {
335335
err = new AbortError();
336336
}
337337

lib/internal/streams/readable.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1150,7 +1150,9 @@ async function* createAsyncIterator(stream, options) {
11501150
(error || options?.destroyOnReturn !== false) &&
11511151
(error === undefined || stream._readableState.autoDestroy)
11521152
) {
1153-
destroyImpl.destroyer(stream, null);
1153+
destroyImpl.destroyer(stream, null, {
1154+
autoAbort: false
1155+
});
11541156
}
11551157
}
11561158
}

test/parallel/test-stream-pipeline.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -764,21 +764,21 @@ const tsp = require('timers/promises');
764764
}));
765765
}
766766

767-
// {
768-
// const s = new PassThrough();
769-
// pipeline(async function*() {
770-
// await Promise.resolve();
771-
// yield 'hello';
772-
// yield 'world';
773-
// }, s, async function(source) {
774-
// for await (const chunk of source) {
775-
// throw new Error('kaboom');
776-
// }
777-
// }, common.mustCall((err, val) => {
778-
// assert.strictEqual(err.message, 'kaboom');
779-
// assert.strictEqual(s.destroyed, true);
780-
// }));
781-
// }
767+
{
768+
const s = new PassThrough();
769+
pipeline(async function*() {
770+
await Promise.resolve();
771+
yield 'hello';
772+
yield 'world';
773+
}, s, async function(source) {
774+
for await (const chunk of source) {
775+
throw new Error('kaboom');
776+
}
777+
}, common.mustCall((err, val) => {
778+
assert.strictEqual(err.message, 'kaboom');
779+
assert.strictEqual(s.destroyed, true);
780+
}));
781+
}
782782

783783
{
784784
const s = new PassThrough();

0 commit comments

Comments
 (0)