Skip to content

fix: validate ReadableStream.from iterator objects#62911

Open
daeyeon wants to merge 1 commit intonodejs:mainfrom
daeyeon:fix-web-stream-regression
Open

fix: validate ReadableStream.from iterator objects#62911
daeyeon wants to merge 1 commit intonodejs:mainfrom
daeyeon:fix-web-stream-regression

Conversation

@daeyeon
Copy link
Copy Markdown
Member

@daeyeon daeyeon commented Apr 23, 2026

This restores validation in ReadableStream.from() so that it throws when the iterator method returns a non-object.

From the spec:

GetIterator(async):

...
iii. Let syncIteratorRecord be ? GetIteratorFromMethod(obj, syncMethod).

  1. Let iterator be ? Call(method, obj).
  2. If iterator is not an Object, throw a TypeError exception. <--
  3. Return ? GetIteratorDirect(iterator).

https://tc39.es/ecma262/multipage/abstract-operations.html#sec-getiterator

@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/web-standards

@panva
Copy link
Copy Markdown
Member

panva commented Apr 23, 2026

@daeyeon can you add a specific regression test?

@nodejs-github-bot nodejs-github-bot added the needs-ci PRs that need a full CI run. label Apr 23, 2026
Comment thread lib/internal/webstreams/readablestream.js Outdated
@daeyeon daeyeon force-pushed the fix-web-stream-regression branch from fd2ff95 to 147a305 Compare April 23, 2026 14:47
Signed-off-by: Daeyeon Jeong <daeyeon.dev@gmail.com>
@daeyeon daeyeon force-pushed the fix-web-stream-regression branch from 147a305 to e3f0af4 Compare April 23, 2026 16:07
@daeyeon
Copy link
Copy Markdown
Member Author

daeyeon commented Apr 23, 2026

@panva Added a test too. PTAL when you have a chance.

@panva panva added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. request-ci Add this label to start a Jenkins CI on a PR. labels Apr 23, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Apr 23, 2026
@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 23, 2026

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #62911      +/-   ##
==========================================
+ Coverage   89.62%   89.63%   +0.01%     
==========================================
  Files         706      706              
  Lines      219203   219206       +3     
  Branches    41996    42001       +5     
==========================================
+ Hits       196454   196482      +28     
+ Misses      14658    14621      -37     
- Partials     8091     8103      +12     
Files with missing lines Coverage Δ
lib/internal/webstreams/readablestream.js 98.54% <100.00%> (+<0.01%) ⬆️

... and 28 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.

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. web streams

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants