Skip to content

Commit 05f1df5

Browse files
committed
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 <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
1 parent 9e3eddc commit 05f1df5

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
@@ -240,7 +240,9 @@ function pipeline(...streams) {
240240
// always returns a stream which can be further
241241
// composed through `.pipe(stream)`.
242242

243-
const pt = new PassThrough();
243+
const pt = new PassThrough({
244+
objectMode: true
245+
});
244246
if (isPromise(ret)) {
245247
ret
246248
.then((val) => {

test/parallel/test-stream-pipeline.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,3 +1065,15 @@ const { promisify } = require('util');
10651065
src.push('asd');
10661066
dst.destroy();
10671067
}
1068+
1069+
{
1070+
pipeline(async function * () {
1071+
yield 'asd';
1072+
}, async function * (source) {
1073+
for await (const chunk of source) {
1074+
yield { chunk };
1075+
}
1076+
}, common.mustCall((err) => {
1077+
assert.ifError(err);
1078+
}));
1079+
}

0 commit comments

Comments
 (0)