Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
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
2 changes: 1 addition & 1 deletion lib/internal/streams/pipeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ function pipe(src, dst, finish, { end }) {
}
});

src.pipe(dst, { end });
src.pipe(dst, { end: false }); // If end is true we already will have a listener to end 'dst'.
Comment thread
debadree25 marked this conversation as resolved.
Outdated

if (end) {
// Compat. Before node v10.12.0 stdio used to throw an error so
Expand Down
35 changes: 35 additions & 0 deletions test/parallel/test-stream-pipeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -1556,3 +1556,38 @@ const tsp = require('timers/promises');
})
);
}

{
class CustomReadable extends Readable {
_read() {
this.push('asd');
this.push(null);
}
}

class CustomWritable extends Writable {
constructor() {
super();
this.endCount = 0;
this.str = '';
}

_write(chunk, enc, cb) {
this.str += chunk;
cb();
}

end() {
this.endCount += 1;
super.end();
}
}

const readable = new CustomReadable();
const writable = new CustomWritable();

pipeline(readable, writable, common.mustSucceed(() => {
assert.strictEqual(writable.str, 'asd');
assert.strictEqual(writable.endCount, 1);
}));
}