diff options
author | Denys Otrishko <shishugi@gmail.com> | 2018-07-10 18:44:16 +0300 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2018-07-14 12:04:53 +0200 |
commit | 35326f27fd9693fcf02a2eab5e22c78b0b702508 (patch) | |
tree | 1da6a8b0e92039e670ad352ebfdf11b447737a1f /doc/api/process.md | |
parent | 998f9ffd429e10b712b06ea57e598d4b1a55fe64 (diff) | |
download | android-node-v8-35326f27fd9693fcf02a2eab5e22c78b0b702508.tar.gz android-node-v8-35326f27fd9693fcf02a2eab5e22c78b0b702508.tar.bz2 android-node-v8-35326f27fd9693fcf02a2eab5e22c78b0b702508.zip |
process: fix process.exitCode handling for fatalException
* set process.exitCode before calling 'exit' handlers so that there will
not be a situation where process.exitCode !== code in 'exit' callback
during uncaughtException handling
* don't ignore process.exitCode set in 'exit' callback when failed with
uncaughtException and there is no uncaughtException listener
PR-URL: https://github.com/nodejs/node/pull/21739
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Diffstat (limited to 'doc/api/process.md')
-rw-r--r-- | doc/api/process.md | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/doc/api/process.md b/doc/api/process.md index edf01258c3..df544e7f0f 100644 --- a/doc/api/process.md +++ b/doc/api/process.md @@ -151,9 +151,13 @@ added: v0.1.18 The `'uncaughtException'` event is emitted when an uncaught JavaScript exception bubbles all the way back to the event loop. By default, Node.js -handles such exceptions by printing the stack trace to `stderr` and exiting. +handles such exceptions by printing the stack trace to `stderr` and exiting +with code 1, overriding any previously set [`process.exitCode`][]. Adding a handler for the `'uncaughtException'` event overrides this default -behavior. +behavior. You may also change the [`process.exitCode`][] in +`'uncaughtException'` handler which will result in process exiting with +provided exit code, otherwise in the presence of such handler the process will +exit with 0. The listener function is called with the `Error` object passed as the only argument. |