diff options
author | Yoshiya Hinosawa <stibium121@gmail.com> | 2021-01-21 16:44:48 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-21 16:44:48 +0900 |
commit | 18ac7d40c87b380ce5ed617bd7c59e344730a883 (patch) | |
tree | 2588d833bed775c22756db9e18742ec736e498da /runtime/js/30_os.js | |
parent | 8bef29fd74f24e3682069a1188386d90805a9904 (diff) |
fix(runtime): fix recursive dispatches of unload event (#9207)
Diffstat (limited to 'runtime/js/30_os.js')
-rw-r--r-- | runtime/js/30_os.js | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/runtime/js/30_os.js b/runtime/js/30_os.js index 1d700b561..5a3c990b0 100644 --- a/runtime/js/30_os.js +++ b/runtime/js/30_os.js @@ -24,9 +24,12 @@ } function exit(code = 0) { - // Invokes the `unload` hooks before exiting - // ref: https://github.com/denoland/deno/issues/3603 - window.dispatchEvent(new Event("unload")); + // Dispatches `unload` only when it's not dispatched yet. + if (!window[Symbol.for("isUnloadDispatched")]) { + // Invokes the `unload` hooks before exiting + // ref: https://github.com/denoland/deno/issues/3603 + window.dispatchEvent(new Event("unload")); + } core.jsonOpSync("op_exit", { code }); throw new Error("Code not reachable"); } |