process: delay setup of global exception handlers

Since bootstrap/node.js performs the setup synchronously,
the process exception handlers do not have to setup so early in
the bootstrap process - any fatal errors thrown before user code
execution should simply crash the process, and we do not care
about any clean up at that point. We don't care about emitting any
events if the process crash upon bootstrap either.

PR-URL: https://github.com/nodejs/node/pull/26061
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
Reviewed-By: Gus Caplan <me@gus.host>
This commit is contained in:
Joyee Cheung 2019-02-10 19:00:54 +08:00 committed by Anna Henningsen
parent 66942d7d86
commit 0eb71d4213
No known key found for this signature in database
GPG Key ID: 9C63F3A6CD2AD8F9

View File

@ -46,24 +46,6 @@ setupTraceCategoryState();
setupProcessObject();
// TODO(joyeecheung): this does not have to done so early, any fatal errors
// thrown before user code execution should simply crash the process
// and we do not care about any clean up at that point. We don't care
// about emitting any events if the process crash upon bootstrap either.
{
const {
fatalException,
setUncaughtExceptionCaptureCallback,
hasUncaughtExceptionCaptureCallback
} = NativeModule.require('internal/process/execution');
process._fatalException = fatalException;
process.setUncaughtExceptionCaptureCallback =
setUncaughtExceptionCaptureCallback;
process.hasUncaughtExceptionCaptureCallback =
hasUncaughtExceptionCaptureCallback;
}
setupGlobalProxy();
setupBuffer();
@ -265,6 +247,20 @@ Object.defineProperty(process, 'features', {
}
});
{
const {
fatalException,
setUncaughtExceptionCaptureCallback,
hasUncaughtExceptionCaptureCallback
} = NativeModule.require('internal/process/execution');
process._fatalException = fatalException;
process.setUncaughtExceptionCaptureCallback =
setUncaughtExceptionCaptureCallback;
process.hasUncaughtExceptionCaptureCallback =
hasUncaughtExceptionCaptureCallback;
}
// User-facing NODE_V8_COVERAGE environment variable that writes
// ScriptCoverage to a specified file.
if (process.env.NODE_V8_COVERAGE) {