Skip to content

Preserve queued async generator ordering - #4568

Open
Aghayenoor wants to merge 1 commit into
evanw:mainfrom
Aghayenoor:fix/4566-async-generator-order
Open

Aghayenoor wants to merge 1 commit into
evanw:mainfrom
Aghayenoor:fix/4566-async-generator-order

Conversation

@Aghayenoor

Copy link
Copy Markdown

When esbuild lowers an async generator, each queued request waits for a promise reaction before resuming the generator. This can run the previous request’s .then() handler before the next part of the generator body, reversing the order seen with native async generators.

Keep an explicit FIFO queue and start the next request as soon as the current one settles. A synchronous throw rejects its request and advances the queue.

Fixes #4566.

go test ./... and node scripts/end-to-end-tests.js passed. The ordering regression fails before the fix and passes in both native and lowered execution afterward. The test also covers a queued throw() followed by next().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lowered async generator suspends between queued next() requests (body runs after the previous request's reactions)

1 participant