From 05f1df520064475a255d8956f9e1b6f4bf4c8543 Mon Sep 17 00:00:00 2001 From: Robert Nagy Date: Sat, 21 Mar 2020 22:15:40 +0100 Subject: [PATCH] stream: fix pipeline with dest in objectMode pipeline did not support destination with generator that does not return strings or buffers. PR-URL: https://github.com/nodejs/node/pull/32414 Reviewed-By: Matteo Collina Reviewed-By: Luigi Pinca Reviewed-By: James M Snell Reviewed-By: Trivikram Kamat --- lib/internal/streams/pipeline.js | 4 +++- test/parallel/test-stream-pipeline.js | 12 ++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) 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); + })); +}