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

Module graphs with TLA can hang #3356

Closed
syg opened this issue Jun 21, 2024 · 0 comments · Fixed by #3357
Closed

Module graphs with TLA can hang #3356

syg opened this issue Jun 21, 2024 · 0 comments · Fixed by #3357
Labels

Comments

@syg
Copy link
Contributor

syg commented Jun 21, 2024

There's a spec bug in step 12.c.iii.1 of AsyncModuleExecutionFulfilled where m.[[Status]] is transitioned to ~evaluated~ but m.[[AsyncEvaluation]] is unchanged. Because m.[[AsyncEvaluation]] remains true, step 11.c.v of InnerModuleEvaluation can add an already-evaluated module as an async parent, which results in a hang.

See https://github.com/nicolo-ribaudo/es-modules-tla-bug for a minimal repro.

@syg syg added the spec bug label Jun 21, 2024
syg added a commit to syg/ecma262 that referenced this issue Jun 21, 2024
Closes tc39#3356.

Modules that depend on modules with top-level await but do not
themselves have a top-level await may currently hang. When a module with
TLA finishes evaluating, it triggers evaluation of ancestors modules
that depend on it.

Currently, ancestors that do not have TLA themselves are evaluated and
have their [[Status]] set to ~evaluated~ but incorrectly leaves their
[[AsyncEvaluation]] field unchanged as true. This means subsequent
importers of those ancestors consider them as in the middle of async
evaluation and will wait on them in InnerModuleEvaluation. But since
they are already evaluated, those waits cause a hang.

This PR sets [[AsyncEvaluation]] to false for those ancestors when their
[[Status]] transition to ~evaluated~.

Note that the ancestors that error out during evaluation do not need
this fix because there is a bail-out path for errored out modules in
InnerModuleEvaluation.
ljharb pushed a commit to syg/ecma262 that referenced this issue Aug 17, 2024
Closes tc39#3356.

Modules that depend on modules with top-level await but do not
themselves have a top-level await may currently hang. When a module with
TLA finishes evaluating, it triggers evaluation of ancestors modules
that depend on it.

Currently, ancestors that do not have TLA themselves are evaluated and
have their [[Status]] set to ~evaluated~ but incorrectly leaves their
[[AsyncEvaluation]] field unchanged as true. This means subsequent
importers of those ancestors consider them as in the middle of async
evaluation and will wait on them in InnerModuleEvaluation. But since
they are already evaluated, those waits cause a hang.

This PR sets [[AsyncEvaluation]] to false for those ancestors when their
[[Status]] transition to ~evaluated~.

Note that the ancestors that error out during evaluation do not need
this fix because there is a bail-out path for errored out modules in
InnerModuleEvaluation.

 - Set [[AsyncEvaluation]] to false in rejection closure for symmetry
@ljharb ljharb closed this as completed in ac21460 Aug 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant