From 26947993f16b97c1c535d2c061d43e9faae73362 Mon Sep 17 00:00:00 2001 From: Robert Nagy Date: Fri, 19 Nov 2021 19:35:21 +0100 Subject: [PATCH] fixup --- lib/internal/streams/pipeline.js | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/lib/internal/streams/pipeline.js b/lib/internal/streams/pipeline.js index 6f2af221f4f109..f5f489577854ac 100644 --- a/lib/internal/streams/pipeline.js +++ b/lib/internal/streams/pipeline.js @@ -232,15 +232,19 @@ function pipelineImpl(streams, callback, opts) { const end = reading || opts?.end !== false; if (isNodeStream(stream)) { - finishCount++; - destroys.push(destroyer(stream, reading, end && writing, (err) => { - if (!err && !reading && isReadableFinished(stream, false)) { - stream.read(0); - destroyer(stream, true, writing, finish); - } else { - finish(err); - } - })); + if (end) { + finishCount++; + destroys.push(destroyer(stream, reading, writing, (err) => { + if (!err && !reading && isReadableFinished(stream, false)) { + stream.read(0); + destroyer(stream, true, writing, finish); + } else { + finish(err); + } + })); + } else { + stream.on('error', finish); + } } if (i === 0) {