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 inputs without a synchronous
iteration path, allowing dual sync/async iterables and thenable sync
iterables to be consumed through their synchronous iterator.


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
Comment thread lib/internal/streams/iter/from.js Outdated

@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

This comment was marked as outdated.

When an input provides Symbol.iterator, fromSync() should consume the
synchronous iterator instead of rejecting the input because it also
exposes an asynchronous or promise-like protocol.

Continue rejecting async-only iterables and promise/thenable-only
inputs, but allow sync iterables that also define Symbol.asyncIterator
or then().

Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com>
Assisted-by: openai:gpt-5.5
@trivikr trivikr force-pushed the stream-iter-fromsync-iter branch from 1e713e7 to f21d604 Compare July 6, 2026 06:17
@trivikr trivikr requested a review from aduh95 July 6, 2026 06:20
@trivikr trivikr added the request-ci Add this label to start a Jenkins CI on a PR. label Jul 6, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jul 7, 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

5 participants