stream: flush each fused stateless transform · nodejs/node@4f40a85 · GitHub
Skip to content

Commit 4f40a85

Browse files
trivikraduh95
authored andcommitted
stream: flush each fused stateless transform
Ensure consecutive stateless stream/iter transforms each receive a final null flush after upstream flush output has been processed. Fixes: #63467 Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com> Assisted-by: openai:gpt-5.5 PR-URL: #63468 Fixes: #63467 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 885d246 commit 4f40a85

3 files changed

Lines changed: 76 additions & 30 deletions

File tree

lib/internal/streams/iter/pull.js

Lines changed: 47 additions & 30 deletions

test/parallel/test-stream-iter-pull-async.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,19 @@ async function testPullStatelessTransformFlush() {
233233
assert.strictEqual(data, 'data-TRAILER');
234234
}
235235

236+
// Consecutive stateless transforms each receive a final flush signal after
237+
// upstream flush output has been processed.
238+
async function testPullConsecutiveStatelessTransformFlush() {
239+
const enc = new TextEncoder();
240+
const addAOnFlush = (chunks) => (chunks === null ?
241+
[enc.encode('-A')] : chunks);
242+
const addBOnFlush = (chunks) => (chunks === null ?
243+
[enc.encode('-B')] : chunks);
244+
245+
const data = await text(pull(from('x'), addAOnFlush, addBOnFlush));
246+
assert.strictEqual(data, 'x-A-B');
247+
}
248+
236249
// Stateless transform flush error propagates
237250
async function testPullStatelessTransformFlushError() {
238251
const badFlush = (chunks) => {
@@ -357,6 +370,7 @@ async function testTransformOptionsNotShared() {
357370
testPullStatelessTransformError(),
358371
testPullStatefulTransformError(),
359372
testPullStatelessTransformFlush(),
373+
testPullConsecutiveStatelessTransformFlush(),
360374
testPullStatelessTransformFlushError(),
361375
testPullWithSyncSource(),
362376
testPullStringSource(),

test/parallel/test-stream-iter-pull-sync.js

Lines changed: 15 additions & 0 deletions

0 commit comments

Comments
 (0)