diff --git a/lib/internal/streams/pipeline.js b/lib/internal/streams/pipeline.js index 36e1aebdd10e10..a3f69c2099ace1 100644 --- a/lib/internal/streams/pipeline.js +++ b/lib/internal/streams/pipeline.js @@ -288,7 +288,9 @@ function pipelineImpl(streams, callback, opts) { then.call(ret, (val) => { value = val; - pt.write(val); + if (val != null) { + pt.write(val); + } if (end) { pt.end(); } diff --git a/test/parallel/test-stream-pipeline.js b/test/parallel/test-stream-pipeline.js index 1948eeef8af257..a5d92fa334e3ff 100644 --- a/test/parallel/test-stream-pipeline.js +++ b/test/parallel/test-stream-pipeline.js @@ -1511,3 +1511,19 @@ const tsp = require('timers/promises'); assert.strictEqual(s.destroyed, true); })); } + + +{ + const s = new PassThrough({ objectMode: true }); + pipeline(async function*() { + await Promise.resolve(); + yield 'hello'; + yield 'world'; + yield 'world'; + }, s, async function(source) { + return null; + }, common.mustCall((err, val) => { + assert.strictEqual(err, undefined); + assert.strictEqual(val, null); + })); +}