forked from denoland/deno
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(realms): Make realm creation not hang with async ops running (den…
…oland#99) The way `JsRuntime::init_extension_js` initialized ESM extensions without a snapshot was by running the event loop and blocking the thread ntil there were no more tasks. This works fine for the main realm, because it is created before any user code can start any async ops. However, other realms may be created while async ops are running, which would make realm creation hang until those ops are resolved. Since extensions are not expected to use top-level await, there would be no need to run the entire event loop for modules to resolve; calling `JsRealm::evaluate_pending_module` would be enough. If the module is not resolved after calling that functions, then it or one of its dependencies has TLA, in which case we panic. Since a panic like "TLA is not allowed" would be hard to debug, especially on codebases with many modules, we use `ModuleMap::find_stalled_top_level_await` to find at least one of the TLA locations, and we display it in the panic message.
- Loading branch information
1 parent
2f37bbc
commit 58a8f6d
Showing
3 changed files
with
114 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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