Skip to content

stream: prefer sync iterator in fromSync#64294

Merged
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
trivikr:stream-iter-fromsync-iter
Jul 8, 2026
Merged

stream: prefer sync iterator in fromSync#64294
nodejs-github-bot merged 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.

@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

This comment was marked as outdated.

@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 f21d604 to ce6448e Compare July 8, 2026 00:38
@trivikr

This comment was marked as outdated.

@trivikr trivikr added the request-ci Add this label to start a Jenkins CI on a PR. label Jul 8, 2026
@codecov

codecov Bot commented Jul 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.25%. Comparing base (4ee2117) to head (ce6448e).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #64294      +/-   ##
==========================================
+ Coverage   90.23%   90.25%   +0.01%     
==========================================
  Files         741      741              
  Lines      240979   240984       +5     
  Branches    45401    45409       +8     
==========================================
+ Hits       217449   217500      +51     
+ Misses      15112    15068      -44     
+ Partials     8418     8416       -2     
Files with missing lines Coverage Δ
lib/internal/streams/iter/from.js 88.18% <100.00%> (+0.09%) ⬆️

... and 30 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

Copy link
Copy Markdown
Collaborator

@trivikr trivikr added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. commit-queue Add this label to land a pull request using GitHub Actions. labels Jul 8, 2026
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Jul 8, 2026
@nodejs-github-bot nodejs-github-bot merged commit 91b65a4 into nodejs:main Jul 8, 2026
76 checks passed
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Landed in 91b65a4

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

Labels

author ready PRs that have at least one approval, no pending requests for changes, and a CI started. 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