Skip to content

stream/iter: writer.fail(0) can leave async iterator readers pending forever #63568

@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';
import { setTimeout } from 'node:timers/promises';

const { writer, readable } = push();
const reader = readable[Symbol.asyncIterator]();

writer.fail(0);

const result = await Promise.race([
  reader.next().then(
    (value) => ({ type: 'settled', value }),
    (reason) => ({ type: 'rejected', reason }),
  ),
  setTimeout(100, { type: 'timeout' }),
]);

console.log(result);

How often does it reproduce? Is there a required condition?

Always

What is the expected behavior? Why is that the expected behavior?

{ type: 'rejected', reason: 0 }

next() should reject with the stored failure reason, including falsy values such as 0 or false, because fail(reason) accepts any value.

What do you see instead?

{ type: 'timeout' }

After calling writer.fail(0), a subsequent readable[Symbol.asyncIterator]().next() does not settle and the repro times out.

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