Add tests for iterator close semantics of Array.fromAsync - #5095
Open
littledivy wants to merge 1 commit into
Open
Add tests for iterator close semantics of Array.fromAsync#5095littledivy wants to merge 1 commit into
littledivy wants to merge 1 commit into
Conversation
littledivy
force-pushed
the
fromasync-iterator-close-tests
branch
from
July 24, 2026 14:12
7e94308 to
0de3c0a
Compare
The existing fromAsync tests cover that an abrupt mapper completion closes the iterator, but not the surrounding close semantics: - a normal completion (done: true) must not call return() - the close is awaited: the promise from return() settles before the promise returned by Array.fromAsync is rejected - when both the mapper and return() fail, the promise rejects with the mapper's error (AsyncIteratorClose returns the original completion) These distinguish implementations today: quickjs-ng closed exhausted iterators without awaiting, and V8 never settles the returned promise when return() throws or rejects during an abrupt close.
littledivy
force-pushed
the
fromasync-iterator-close-tests
branch
from
July 24, 2026 15:24
0de3c0a to
7f29aa5
Compare
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The existing
Array.fromAsynctests cover that an abrupt mapper completion closes the iterator (mapfn-*-throws-close-*-iterator.js), but not the surrounding close semantics:does-not-close-exhausted-async-iterator.js/does-not-close-exhausted-sync-iterator.js: a normal completion (done: true) must not callreturn(); iteration ends with a return completion, never AsyncIteratorClose.mapfn-throws-close-async-iterator-awaited.js: the close is awaited, so the promise fromreturn()settles before the promise returned byArray.fromAsyncis rejected (AsyncIteratorClose step 5.d).mapfn-throws-close-rejection-not-masked.js: when both the mapper andreturn()fail, the promise rejects with the mapper's error (AsyncIteratorClose step 6 returns the original completion).These distinguish implementations today: quickjs-ng closed exhausted iterators without awaiting the result (fix in quickjs-ng/quickjs#1596, which prompted these tests), and V8 (Node 24.14) never settles the returned promise at all when
return()throws or rejects during an abrupt close, so the last test currently hangs there.