Skip to content

Commit b7a8878

Browse files
ronagMylesBorins
authored andcommitted
stream: fix pipeline with dest in objectMode
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>
1 parent 0185e3a commit b7a8878

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

lib/internal/streams/pipeline.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,9 @@ function pipeline(...streams) {
228228
// always returns a stream which can be further
229229
// composed through `.pipe(stream)`.
230230

231-
const pt = new PassThrough();
231+
const pt = new PassThrough({
232+
objectMode: true
233+
});
232234
if (isPromise(ret)) {
233235
ret
234236
.then((val) => {

test/parallel/test-stream-pipeline.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,3 +1049,15 @@ const { promisify } = require('util');
10491049
src.push('asd');
10501050
dst.destroy();
10511051
}
1052+
1053+
{
1054+
pipeline(async function * () {
1055+
yield 'asd';
1056+
}, async function * (source) {
1057+
for await (const chunk of source) {
1058+
yield { chunk };
1059+
}
1060+
}, common.mustCall((err) => {
1061+
assert.ifError(err);
1062+
}));
1063+
}

0 commit comments

Comments
 (0)