1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-25 08:39:09 -05:00
denoland-deno/cli/tests/top_level_await_bug2.js
Bartek Iwańczuk c7c7677825
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.
2020-10-06 10:18:22 +02:00

15 lines
310 B
JavaScript

const mod = await import("./top_level_await_bug_nested.js");
console.log(mod);
const sleep = (n) => new Promise((r) => setTimeout(r, n));
await sleep(100);
console.log("slept");
window.addEventListener("load", () => {
console.log("load event");
});
setTimeout(() => {
console.log("timeout");
}, 1000);