fix: top-level-await module execution (#7946)

This commit changes implementation of top-level-await in "deno_core".

Previously promise returned from module evaluation was not awaited,
leading to out-of-order execution of modules that have TLA. It's been
fixed by changing "JsRuntime::mod_evaluate" to be an async function
that resolves when the promise returned from module evaluation also
resolves. When waiting for promise resolution event loop is polled
repeatedly, until there are no more dynamic imports or pending
ops.
This commit is contained in:
Bartek Iwańczuk 2020-10-14 14:04:09 +02:00 committed by GitHub
parent 10654fa955
commit 135053486c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 479 additions and 40 deletions

View file

@ -191,7 +191,7 @@ impl Worker {
) -> Result<(), AnyError> {
let id = self.preload_module(module_specifier).await?;
self.wait_for_inspector_session();
self.js_runtime.mod_evaluate(id)
self.js_runtime.mod_evaluate(id).await
}
/// Returns a way to communicate with the Worker from other threads.