Version
26.2.0
Platform
Subsystem
stream
What steps will reproduce the bug?
import { push } from 'node:stream/iter';
const { writer, readable } = push();
writer.writeSync('hello');
const events = [];
writer.end().then(() => {
events.push('end resolved');
});
await Promise.resolve();
events.push('after microtask');
for await (const _ of readable) {
events.push('readable drained');
}
console.log(events);
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior? Why is that the expected behavior?
[ 'after microtask', 'readable drained', 'end resolved' ]
writer.end() should stay pending until the readable drains, so end resolved should appear after readable drained.
What do you see instead?
[ 'end resolved', 'after microtask', 'readable drained' ]
writer.end() currently resolves before the readable side consumes the buffered "hello" chunk
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?
[ 'after microtask', 'readable drained', 'end resolved' ]writer.end()should stay pending until the readable drains, so end resolved should appear after readable drained.What do you see instead?
[ 'end resolved', 'after microtask', 'readable drained' ]writer.end()currently resolves before the readable side consumes the buffered"hello"chunkAdditional information
No response