Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ext/web): ReadableStream.from() ignores null Symbol.asyncIterator #23910

Merged
merged 3 commits into from
May 23, 2024

Conversation

Milly
Copy link
Contributor

@Milly Milly commented May 21, 2024

If @@asyncIterator is null or undefined, it should ignores and fallback to @@iterator.

Tests have been merged into WPT.
web-platform-tests/wpt#46374

The proposal of ReadableStream.from uses TC39 GetIterator and GetMethod within it.
GetMethod treats null as undefined.
So if @@asyncIterator is null it should be ignored and fallback to @@iterator.

> deno eval "ReadableStream.from({ [Symbol.asyncIterator]: null, [Symbol.iterator]: () => ({ next: () => ({ done: true }) }) }).pipeTo(new WritableStream())"
error: Uncaught (in promise) TypeError: obj[SymbolAsyncIterator] is not a function
ReadableStream.from({ [Symbol.asyncIterator]: null, [Symbol.iterator]: () => ({ next: () => ({ done: true }) }) }).pipeTo(new WritableStream())
               ^
    at getIterator (ext:deno_web/06_streams.js:5105:38)
    at Function.from (ext:deno_web/06_streams.js:5207:22)
    at file:https:///D:/work/js/deno/tests/wpt/suite/$deno$eval:1:16

If `@@asyncIterator` is `null` or `undefined`, it should ignores and
fallback to `@@iterator`.

Tests have been merged into WPT.
web-platform-tests/wpt#46374
@Milly Milly changed the title fix(ext/web): ReadableStream.from() ignores null fix(ext/web): ReadableStream.from() ignores null Symbol.asyncIterator May 21, 2024
@bartlomieju
Copy link
Member

@iuioiua can you take care of this PR by updating the WPT after #23823 lands?

@bartlomieju bartlomieju added this to the 1.44 milestone May 22, 2024
@iuioiua iuioiua changed the title fix(ext/web): ReadableStream.from() ignores null Symbol.asyncIterator fix(ext/web): ReadableStream.from() ignores null Symbol.asyncIterator May 22, 2024
@iuioiua
Copy link
Collaborator

iuioiua commented May 23, 2024

WPT updated. The test for this change, /streams/readable-streams/from.any.html - ReadableStream.from ignores a null @@asyncIterator, passes.

Comment on lines +3174 to +3175
"ReadableStream.from accepts a sync iterable of values",
"ReadableStream.from accepts a sync iterable of promises"
Copy link
Collaborator

Choose a reason for hiding this comment

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

These should be fixed by #23903.

tests/wpt/runner/expectation.json Show resolved Hide resolved
Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

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

LGTM, thanks

@bartlomieju bartlomieju merged commit fa27350 into denoland:main May 23, 2024
17 checks passed
@Milly Milly deleted the fix-readablestream-from-null branch May 23, 2024 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants