Version
26.2.0
Platform
Subsystem
stream
What steps will reproduce the bug?
import{setTimeoutasdelay}from'node:timers/promises';import{pipeToSync,push}from'node:stream/iter';constdecoder=newTextDecoder();const{ writer, readable }=push({highWaterMark: 1});consttotal=pipeToSync(['a','b'],writer,{preventClose: true});constiter=readable[Symbol.asyncIterator]();constfirst=awaititer.next();constsecond=awaitPromise.race([iter.next().then((r)=>r.done ? '<done>' : decoder.decode(r.value[0])),delay(20,'<no second chunk>'),]);awaititer.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: 1first buffered chunk: asecond 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: 2first buffered chunk: asecond 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