Skip to content
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 #51725

Closed
MattiasBuelens opened this issue Feb 11, 2024 · 3 comments · Fixed by #52657
Closed

Update ongoing promise in async iterator return() method #51725

MattiasBuelens opened this issue Feb 11, 2024 · 3 comments · Fixed by #52657
Labels
confirmed-bug Issues with confirmed bugs.

Comments

@MattiasBuelens
Copy link
Contributor

MattiasBuelens commented Feb 11, 2024

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:

return(error) {
return state.current ?
PromisePrototypeThen(
state.current,
() => returnSteps(error),
() => returnSteps(error)) :
returnSteps(error);
},

@aduh95
Copy link
Contributor

aduh95 commented Feb 12, 2024

/cc @nodejs/whatwg-stream

@mcollina
Copy link
Member

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

@mcollina mcollina added the confirmed-bug Issues with confirmed bugs. label Feb 13, 2024
@MattiasBuelens
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed-bug Issues with confirmed bugs.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants