Handler: ((code: number | null | undefined, signal: NodeJS.Signals | null) => true | void)
Type declaration
-
- (code: number | null | undefined, signal: NodeJS.Signals | null): true | void
-
Parameters
-
code: number | null | undefined
-
signal: NodeJS.Signals | null
Returns true | void
A function that takes an exit code and signal as arguments
In the case of signal exits only, a return value of true will indicate that the signal is being handled, and we should not synthetically exit with the signal we received. Regardless of the handler return value, the handler is unloaded when an otherwise fatal signal is received, so you get exactly 1 shot at it, unless you add another onExit handler at that point.
In the case of numeric code exits, we may already have committed to exiting the process, for example via a fatal exception or unhandled promise rejection, so it is impossible to stop safely.