Skip to content

Commit

Permalink
stream: fix pipeline with dest in objectMode
Browse files Browse the repository at this point in the history
pipeline did not support destination with generator
that does not return strings or buffers.

PR-URL: #32414
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
  • Loading branch information
ronag authored and MylesBorins committed Mar 25, 2020
1 parent 0185e3a commit b7a8878
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/internal/streams/pipeline.js
Expand Up @@ -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) => {
Expand Down
12 changes: 12 additions & 0 deletions test/parallel/test-stream-pipeline.js
Expand Up @@ -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);
}));
}

0 comments on commit b7a8878

Please sign in to comment.