Skip to content

stream/iter: fromSync() rejects dual sync/async iterables instead of using Symbol.iterator #64292

Description

@trivikr

Version

main

Platform

macOS 26.5.0

Subsystem

stream

What steps will reproduce the bug?

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

const input = {
  *[Symbol.iterator]() {
    yield new TextEncoder().encode('sync');
  },
  async *[Symbol.asyncIterator]() {
    yield new TextEncoder().encode('async');
  },
};

try {
  console.log(textSync(fromSync(input)));
} catch (err) {
  console.log(`${err.name}: ${err.message}`);
}

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

Always

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

sync

fromSync() currently rejects any object with Symbol.asyncIterator before checking for Symbol.iterator. Per Spec §8.2, only async-only inputs should be rejected here; a dual sync+async iterable should be accepted through its synchronous iterator.

What do you see instead?

TypeError: The "input" argument must be an a synchronous input (not AsyncIterable). Received an instance of Object

Additional information

No response

Metadata

Metadata

Assignees

Labels

streamIssues and PRs related to the stream subsystem.

Type

No type

Fields

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