diff --git a/lib/internal/streams/pipeline.js b/lib/internal/streams/pipeline.js index 51bd99b654f23d..fdba5ebc737206 100644 --- a/lib/internal/streams/pipeline.js +++ b/lib/internal/streams/pipeline.js @@ -240,7 +240,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 c04ae94a7ed357..c2b454e80b38af 100644 --- a/test/parallel/test-stream-pipeline.js +++ b/test/parallel/test-stream-pipeline.js @@ -1065,3 +1065,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); + })); +}