stream: fix nested async flushing with infinite sources · nodejs/node@4b29051 · GitHub
Skip to content

Commit 4b29051

Browse files
jasnelladuh95
authored andcommitted
stream: fix nested async flushing with infinite sources
Signed-off-by: James M Snell <jasnell@gmail.com> Assisted-by: Opencode PR-URL: #65658 Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
1 parent 2e54186 commit 4b29051

3 files changed

Lines changed: 32 additions & 2 deletions

File tree

‎doc/api/stream_iter.md‎

Lines changed: 2 additions & 1 deletion

‎lib/internal/streams/iter/from.js‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,9 +363,13 @@ async function* normalizeAsyncSource(source) {
363363
continue;
364364
}
365365
// Slow path: normalize the value
366-
const batch = [];
366+
let batch = [];
367367
for await (const chunk of normalizeAsyncValue(value)) {
368368
ArrayPrototypePush(batch, chunk);
369+
if (batch.length === FROM_BATCH_SIZE) {
370+
yield batch;
371+
batch = [];
372+
}
369373
}
370374
if (batch.length > 0) {
371375
yield batch;

‎test/parallel/test-stream-iter-from-async.js‎

Lines changed: 25 additions & 0 deletions

0 commit comments

Comments
 (0)