Closed evilpie closed 1 year ago
You're right, this can be an assert. 👍
Same thing for the async iterator return steps: Web IDL guarantees that this will only be called when the iterator's "is finished" is still false
, and it immediately sets it to true
after running those steps for the first (and only) time.
The Web IDL machinery for async iteration did not yet exist when we first specced this in #980, so these checks were necessary back then. But nowadays, we can rely on Web IDL instead.
Step 2 of https://streams.spec.whatwg.org/#rs-asynciterator-prototype-next should be impossible. The reader is acquired internally, so the stream can only become
undefined
after some kind of error or after finishing the iteration.https://webidl.spec.whatwg.org/#es-asynchronous-iterator-prototype-object tells us that "getting the next iteration result" in Step 8.4 can not be invoked when the iteration is finished (Step 8.2).