0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-03-03 09:31:22 -05:00

fix(cli): dispatch unload on exit (#9088)

This commit is contained in:
Yoshiya Hinosawa 2021-01-12 19:32:58 +09:00 committed by GitHub
parent 5c6ab75de1
commit fd56fa89f3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 0 deletions

View file

@ -0,0 +1,4 @@
window.onunload = () => {
console.log("onunload is called");
};
Deno.exit(0);

View file

@ -0,0 +1 @@
[WILDCARD]onunload is called

View file

@ -2646,6 +2646,11 @@ itest!(_077_fetch_empty {
exit_code: 1,
});
itest!(_078_unload_on_exit {
args: "run 078_unload_on_exit.ts",
output: "078_unload_on_exit.ts.out",
});
itest!(js_import_detect {
args: "run --quiet --reload js_import_detect.ts",
output: "js_import_detect.ts.out",

View file

@ -24,6 +24,9 @@
}
function exit(code = 0) {
// 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");
}