From 2930afabceb7ff0dfe3ab77119559cf738cde604 Mon Sep 17 00:00:00 2001 From: Robert Nagy Date: Fri, 19 Nov 2021 19:31:56 +0100 Subject: [PATCH] fixup --- lib/internal/streams/pipeline.js | 2 +- test/parallel/test-stream-pipeline.js | 23 ++++++++++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/lib/internal/streams/pipeline.js b/lib/internal/streams/pipeline.js index 69c94a1f42977a..6f2af221f4f109 100644 --- a/lib/internal/streams/pipeline.js +++ b/lib/internal/streams/pipeline.js @@ -233,7 +233,7 @@ function pipelineImpl(streams, callback, opts) { if (isNodeStream(stream)) { finishCount++; - destroys.push(destroyer(stream, reading, writing, (err) => { + destroys.push(destroyer(stream, reading, end && writing, (err) => { if (!err && !reading && isReadableFinished(stream, false)) { stream.read(0); destroyer(stream, true, writing, finish); diff --git a/test/parallel/test-stream-pipeline.js b/test/parallel/test-stream-pipeline.js index 1fc3386fc16257..ae4e76352f3545 100644 --- a/test/parallel/test-stream-pipeline.js +++ b/test/parallel/test-stream-pipeline.js @@ -1465,5 +1465,26 @@ const tsp = require('timers/promises'); assert.strictEqual(duplex.destroyed, true); } - run(); + run().then(common.mustCall()); +} + +{ + const pipelinePromise = promisify(pipeline); + + async function run() { + const read = new Readable({ + read() {} + }); + + const duplex = new PassThrough(); + + read.push(null); + + await pipelinePromise(read, duplex, { end: false }); + + assert.strictEqual(duplex.destroyed, false); + assert.strictEqual(duplex.writableEnded, false); + } + + run().then(common.mustCall()); }