mirror of
https://github.com/denoland/deno.git
synced 2025-08-04 10:59:13 +00:00
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:
parent
10654fa955
commit
135053486c
23 changed files with 479 additions and 40 deletions
|
@ -153,9 +153,15 @@ fn run_worker_thread(
|
|||
rt.block_on(load_future)
|
||||
};
|
||||
|
||||
if let Err(e) = result {
|
||||
let mut sender = worker.internal_channels.sender.clone();
|
||||
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;
|
||||
}
|
||||
|
||||
if let Err(e) = result {
|
||||
sender
|
||||
.try_send(WorkerEvent::TerminalError(e))
|
||||
.expect("Failed to post message to host");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue