Skip to content

stream/iter: push writer.end() resolves before readable drains buffered data #63502

@trivikr

Description

@trivikr

Version

26.2.0

Platform

macOS 26.5.0

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

Metadata

Metadata

Assignees

Labels

streamIssues and PRs related to the stream subsystem.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions