Re: [whatwg/streams] Use `async iterable` webidl type in ReadableStream.from (PR #1310)

@MattiasBuelens requested changes on this pull request.

Looks good so far! 👍 

Once the Web IDL spec change lands, we'll need to update [webidl2js](https://github.com/jsdom/webidl2js) to implement the new algorithms for async iterables, and then we can update our reference implementation. Let's keep this PR as a draft until that's sorted out.

>   1. Let |cancelAlgorithm| be the following steps, given |reason|:
-  1. Let |iterator| be |iteratorRecord|.\[[Iterator]].
-  1. Let |returnMethod| be [$GetMethod$](|iterator|, "`return`").
-  1. If |returnMethod| is an abrupt completion, return [=a promise rejected with=]
-     |returnMethod|.\[[Value]].
-  1. If |returnMethod|.\[[Value]] is undefined, return [=a promise resolved with=] undefined.
-  1. Let |returnResult| be [$Call$](|returnMethod|.\[[Value]], |iterator|, « |reason| »).

The `reason` argument for the `return()` call is missing in the new spec text.

I propose we add an optional argument to "finish iterating an async iterable" to support this use case, see [my comment on the other PR](https://github.com/whatwg/webidl/pull/1397#discussion_r1538889449).

> -       <!-- TODO (future): If we allow changing the queuing strategy, this Enqueue might throw.
-             We'll then need to catch the error and close the async iterator. -->

Could you restore this comment in the updated spec text? It's still relevant.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/streams/pull/1310#pullrequestreview-1959858514
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/streams/pull/1310/review/1959858514@github.com>

Received on Tuesday, 26 March 2024 09:56:23 UTC