diff --git a/lib/internal/streams/pipeline.js b/lib/internal/streams/pipeline.js index 493a464d07b295..d0e94c5e83337e 100644 --- a/lib/internal/streams/pipeline.js +++ b/lib/internal/streams/pipeline.js @@ -228,7 +228,9 @@ function pipeline(...streams) { // always returns a stream which can be further // composed through `.pipe(stream)`. - const pt = new PassThrough(); + const pt = new PassThrough({ + objectMode: true + }); if (isPromise(ret)) { ret .then((val) => { diff --git a/test/parallel/test-stream-pipeline.js b/test/parallel/test-stream-pipeline.js index 191e8c8471bd1c..f3923bc794fc2f 100644 --- a/test/parallel/test-stream-pipeline.js +++ b/test/parallel/test-stream-pipeline.js @@ -1049,3 +1049,15 @@ const { promisify } = require('util'); src.push('asd'); dst.destroy(); } + +{ + pipeline(async function * () { + yield 'asd'; + }, async function * (source) { + for await (const chunk of source) { + yield { chunk }; + } + }, common.mustCall((err) => { + assert.ifError(err); + })); +}