Version
26.2.0
Platform
Subsystem
stream
What steps will reproduce the bug?
import { setTimeout as delay } from 'node:timers/promises';
import { pipeToSync, push } from 'node:stream/iter';
const decoder = new TextDecoder();
const { writer, readable } = push({ highWaterMark: 1 });
const total = pipeToSync(['a', 'b'], writer, { preventClose: true });
const iter = readable[Symbol.asyncIterator]();
const first = await iter.next();
const second = await Promise.race([
iter.next().then((r) => r.done ? '<done>' : decoder.decode(r.value[0])),
delay(20, '<no second chunk>'),
]);
await iter.return?.();
console.log(`pipeToSync returned: ${total}`);
console.log(`first buffered chunk: ${decoder.decode(first.value[0])}`);
console.log(`second buffered chunk: ${second}`);
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior? Why is that the expected behavior?
pipeToSync returned: 1
first buffered chunk: a
second buffered chunk: <no second chunk>
pipeToSync() should throw or otherwise signal that the second sync write was not accepted. It should not count bytes for a chunk when writeSync() or writevSync() returns false without accepting the data.
What do you see instead?
pipeToSync returned: 2
first buffered chunk: a
second buffered chunk: <no second chunk>
pipeToSync() reports that 2 bytes were written even though the strict push({ highWaterMark: 1 }) writer only accepted a. The failed writeSync('b') return value is ignored, so data is silently dropped and byte accounting is incorrect.
Additional information
No response
Version
26.2.0
Platform
Subsystem
stream
What steps will reproduce the bug?
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior? Why is that the expected behavior?
pipeToSync()should throw or otherwise signal that the second sync write was not accepted. It should not count bytes for a chunk whenwriteSync()orwritevSync()returns false without accepting the data.What do you see instead?
pipeToSync()reports that 2 bytes were written even though the strictpush({ highWaterMark: 1 })writer only accepteda. The failedwriteSync('b')return value is ignored, so data is silently dropped and byte accounting is incorrect.Additional information
No response