From 135053486c4bd112ebd7d0b25c94a8dd346472e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Wed, 14 Oct 2020 14:04:09 +0200 Subject: 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. --- cli/worker.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cli/worker.rs') diff --git a/cli/worker.rs b/cli/worker.rs index 97e39d20c..d9d9f61c1 100644 --- a/cli/worker.rs +++ b/cli/worker.rs @@ -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. -- cgit v1.2.3