Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
handle final
  • Loading branch information
mcollina committed Mar 10, 2020
commit 828abfb3e3da4af6720e7f3f00358e93089e4f72
8 changes: 4 additions & 4 deletions lib/internal/streams/pipeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ let EE;
let PassThrough;
let createReadableStreamAsyncIterator;

function destroyer(stream, reading, writing, callback) {
function destroyer(stream, reading, writing, final, callback) {
const _destroy = once((err) => {
const readable = stream.readable || isRequest(stream);
if (err || !readable) {
if (err || !final || !readable) {
destroyImpl.destroyer(stream, err);
}
callback(err);
Expand Down Expand Up @@ -182,7 +182,7 @@ function pipeline(...streams) {

if (isStream(stream)) {
finishCount++;
destroys.push(destroyer(stream, reading, writing, finish));
destroys.push(destroyer(stream, reading, writing, !reading, finish));
}

if (i === 0) {
Expand Down Expand Up @@ -238,7 +238,7 @@ function pipeline(...streams) {
ret = pt;

finishCount++;
destroys.push(destroyer(ret, false, true, finish));
destroys.push(destroyer(ret, false, true, true, finish));
}
} else if (isStream(stream)) {
if (isReadable(ret)) {
Expand Down