Deno.exit() is an alias to self.close() in worker contexts (#14826)

This commit changes Deno.exit() to be an alias to self.close() in worker contexts,
and the provided exit code becomes is ignored.
This commit is contained in:
Bartek Iwańczuk 2022-06-13 23:53:04 +02:00 committed by GitHub
parent 4a0a412d7c
commit fc3a966a2d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 66 additions and 47 deletions

View file

@ -581,7 +581,6 @@ delete Object.prototype.__proto__;
defineEventHandler(window, "error");
defineEventHandler(window, "load");
defineEventHandler(window, "unload");
const isUnloadDispatched = SymbolFor("isUnloadDispatched");
// Stores the flag for checking whether unload is dispatched or not.
// This prevents the recursive dispatches of unload events.
@ -682,6 +681,11 @@ delete Object.prototype.__proto__;
defineEventHandler(self, "message");
defineEventHandler(self, "error", undefined, true);
// `Deno.exit()` is an alias to `self.close()`. Setting and exit
// code using an op in worker context is a no-op.
os.setExitHandler((_exitCode) => {
workerClose();
});
runtimeStart(
runtimeOptions,