- From: Mattias Buelens <notifications@github.com>
- Date: Thu, 18 Jul 2024 01:35:18 -0700
- To: whatwg/webidl <webidl@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/webidl/pull/1397/review/2185113625@github.com>
@MattiasBuelens commented on this pull request. > +<div id="async-iterable-to-js" algorithm="convert an async iterable to a JavaScript value"> + An IDL <a lt="async iterable type">async iterable<|<var ignore>T</var>></a> value is + [=converted to a JavaScript value|converted=] to a JavaScript object as follows: + + 1. Return the JavaScript object that represents the same async iterable as the IDL value. +</div> Hmm, maybe the real problem is that the IDL machinery should not be calling `GetIterator()` from within the conversion logic in the first place. 🤔 For example: if an IDL operation accepts *two* `async iterable<T>` values as parameters, and `GetIterator()` succeeds for the first value but fails for the second value (e.g. because it's a locked `ReadableStream`), then the operation errors immediately with a `TypeError` but the first value is now permanently "locked". I think we should make "convert from a JavaScript object" *not* call `GetIterator()`: * Make an IDL async iterable *only* represent a JavaScript object. * Add a separate type for an "IDL async iterator", which is represented by a JavaScript `Iterator` record. * Add an "open an async iterable" algorithm, which takes an IDL async iterable, calls `GetIterator()` and returns it as an IDL async iterator. * Refactor the "get the next value of an async iterable" and "close an async iterable" algorithms to work on an IDL async iterator instead. Thoughts? -- Reply to this email directly or view it on GitHub: https://github.com/whatwg/webidl/pull/1397#discussion_r1682442913 You are receiving this because you are subscribed to this thread. Message ID: <whatwg/webidl/pull/1397/review/2185113625@github.com>
Received on Thursday, 18 July 2024 08:35:22 UTC