Skip to content

stream/iter: from() accepts async-only nested values from sync iterables #64351

Description

@trivikr

Version

main

Platform

macOS 26.5.2

Subsystem

stream

What steps will reproduce the bug?

import { from, text } from 'node:stream/iter';

async function* asyncGenerator() {
  yield 'data';
}

try {
  console.log(await text(from([asyncGenerator()])));
} catch (error) {
  console.log(`${error.name}: ${error.code ?? error.message}`);
}

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

Always

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

from([asyncGenerator()]) should throw, because the outer source is a sync iterable and the nested value is async-only.

Spec §8.1 says that when from() treats a sync iterator as an async source, nested async iterables and toAsyncStreamable are unsupported. The sync-iterator fallback currently routes nested values through normalizeAsyncValue(), which accepts async iterables and toAsyncStreamable, so the nested async generator is consumed instead of rejected.

What do you see instead?

data

Additional information

No response

Metadata

Metadata

Assignees

Labels

streamIssues and PRs related to Node.js streams.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions