Skip to content

stream: prefer sync iterator in fromSync#64294

Open
trivikr wants to merge 1 commit into
nodejs:mainfrom
trivikr:stream-iter-fromsync-iter
Open

stream: prefer sync iterator in fromSync#64294
trivikr wants to merge 1 commit into
nodejs:mainfrom
trivikr:stream-iter-fromsync-iter

Conversation

@trivikr

@trivikr trivikr commented Jul 4, 2026

Copy link
Copy Markdown
Member

Fixes: #64292

stream/iter's fromSync() rejected any input that exposed
Symbol.asyncIterator, even when the same input also exposed
Symbol.iterator.

This updates fromSync() to reject only async-only iterables, allowing dual
sync/async iterables to be consumed through their synchronous iterator. A
regression test covers the dual-iterator case.


Assisted-by: openai:gpt-5.5

When an input provides both Symbol.iterator and Symbol.asyncIterator,
fromSync() should consume the synchronous iterator instead of rejecting
the input as async.

Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com>
Assisted-by: openai:gpt-5.5
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/streams

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. stream Issues and PRs related to the stream subsystem. labels Jul 4, 2026
@trivikr trivikr added the request-ci Add this label to start a Jenkins CI on a PR. label Jul 4, 2026
input,
);
}
if (typeof input === 'object' && input !== null && typeof input.then === 'function') {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we also skip this check if input is sync iterable?

@mcollina mcollina left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jul 5, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-ci PRs that need a full CI run. stream Issues and PRs related to the stream subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

4 participants