-
Notifications
You must be signed in to change notification settings - Fork 5.6k
RFC: Add Deno.exitCode
support
#23605
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Not sure, but my first guess would be that the setter would just have to call into https://github.com/denoland/deno/blob/783533d2e354ad73356d7517b26293e48c10fc17/runtime/js/30_os.js#L76C5-L76C21 |
Because the runtime/js/30_os.js file is ESM, we can't actually match the same I don't think that's desired, so instead I'm going to propose that we do this instead: Deno.exit(); // unchanged
Deno.exit.code; //-> number | undefined
Deno.exit.code = 1; //-> void |
At first I found it confusing to have I'm just afraid that users will miss that |
This commits adds the ability to set a would-be exit code for the Deno process without forcing an immediate exit, through the new `Deno.exitCode` API. - **Implements `Deno.exitCode` getter and setter**: Adds support for setting and retrieving a would-be exit code via `Deno.exitCode`. This allows for asynchronous cleanup before process termination without immediately exiting. - **Ensures type safety**: The setter for `Deno.exitCode` validates that the provided value is a number, throwing a TypeError if not, to ensure that only valid exit codes are set. Closes to #23605 --------- Co-authored-by: Bartek Iwańczuk <[email protected]>
I think this can be closed now. |
Closed by #23609 |
Support a new
Deno.exitCode
API that allows user to define the would-be exitcode of the process w/o necessarily forcing an exit that instant (liekDeno.exit()
)This is ideal for tasks that, on error condition, will want to exit as non-healthy but still need to perform some async cleanup tasks before actually exiting.
The text was updated successfully, but these errors were encountered: