node icon indicating copy to clipboard operation
node copied to clipboard

Update ongoing promise in async iterator `return()` method

Open MattiasBuelens opened this issue 3 months ago • 3 comments

There's an edge case with the current Web IDL bindings for async iterators where manually calling return(); next() could result in the next() promise resolving before the return() promise. The latest version of the Web IDL specification fixes this by updating the "ongoing promise" in the async iterator return() method.

For Node.js, this affects ReadableStream.prototype[Symbol.asyncIterator]. More specifically, this part needs to be changed: https://github.com/nodejs/node/blob/a8de25ed1523594dd6bf0ee08a24f146d38cb4e8/lib/internal/webstreams/readablestream.js#L547-L554

MattiasBuelens avatar Feb 11 '24 20:02 MattiasBuelens

/cc @nodejs/whatwg-stream

aduh95 avatar Feb 12 '24 17:02 aduh95

Good finding! Are you planning to send a PR to fix?

mcollina avatar Feb 13 '24 06:02 mcollina

@mcollina Sure, I can do that. I'll wait for the spec change to land first.

MattiasBuelens avatar Feb 13 '24 06:02 MattiasBuelens