From c7c767782538243ded64742dca9b34d6af74d62d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Tue, 6 Oct 2020 10:18:22 +0200 Subject: fix(core): module execution with top level await (#7672) This commit fixes implementation of top level await in "deno_core". Previously promise returned from module execution was ignored causing to execute modules out-of-order. With this commit promise returned from module execution is stored on "JsRuntime" and event loop is polled until the promise resolves. --- cli/ops/worker_host.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'cli/ops') diff --git a/cli/ops/worker_host.rs b/cli/ops/worker_host.rs index 9175ca0f1..17e0e397f 100644 --- a/cli/ops/worker_host.rs +++ b/cli/ops/worker_host.rs @@ -155,6 +155,13 @@ fn run_worker_thread( if let Err(e) = result { let mut sender = worker.internal_channels.sender.clone(); + + // If sender is closed it means that worker has already been closed from + // within using "globalThis.close()" + if sender.is_closed() { + return; + } + sender .try_send(WorkerEvent::TerminalError(e)) .expect("Failed to post message to host"); -- cgit v1.2.3