-
Notifications
You must be signed in to change notification settings - Fork 163
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
Update ongoing promise in async iterator return() method #1387
Update ongoing promise in async iterator return() method #1387
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! I think this is a bugfix and I hope someone from WebKit and/or Mozilla can quickly step up to approve. I take it that it has Chromium support already.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense that they should be aligned. Please file implementation bugs.
Notably, this includes tests for promise resolution order of async iterators in the reference implementation. This requires updating webidl2js. See whatwg/webidl#1387, web-platform-tests/wpt#44456, and jsdom/webidl2js#269 for context.
…hod (#23642) See whatwg/webidl#1387 for context. There are new WPT tests for this change in web-platform-tests/wpt#44456. They pass on my local machine, but I'm not sure if I should update the WPT submodule for all of Deno as part of this PR? Fixes #22389 --------- Co-authored-by: Asher Gomez <ashersaupingomez@gmail.
…hod (#23642) See whatwg/webidl#1387 for context. There are new WPT tests for this change in web-platform-tests/wpt#44456. They pass on my local machine, but I'm not sure if I should update the WPT submodule for all of Deno as part of this PR? Fixes #22389 --------- Co-authored-by: Asher Gomez <ashersaupingomez@gmail.
@yuki3 found an interesting edge case related to async iterators.
In Firefox and Node.js (where async iteration on
ReadableStream
is already supported), when you run this snippet:you get:
This is quite surprising: the second
next()
promise resolves before thereturn()
promise, even though it was called afterreturn()
. Intuitively, we would expect all async iterator calls to get queued. Indeed, if you do the same thing with an async generator:then the promises resolve in the order of the original calls:
Yuki and I believe this to be a bug in the Web IDL specification. More precisely, the
return()
method should update the ongoing promise, such that future calls tonext()
andreturn()
are properly chained. This aligns more closely with the behavior of async generators.Suggested commit message:
ReadableStream.prototype[Symbol.asyncIterator]
, which WebKit doesn't support yet. (https://bugs.webkit.org/show_bug.cgi?id=194379)return()
method denoland/deno#22389return()
method nodejs/node#51725(See WHATWG Working Mode: Changes for more details.)
Preview | Diff