Skip to content

Commit

Permalink
process: delay setup of global exception handlers
Browse files Browse the repository at this point in the history
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: #26061
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
Reviewed-By: Gus Caplan <me@gus.host>
  • Loading branch information
joyeecheung authored and rvagg committed Feb 28, 2019
1 parent 0c4353a commit b5fe27c
Showing 1 changed file with 14 additions and 18 deletions.
32 changes: 14 additions & 18 deletions lib/internal/bootstrap/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -303,6 +285,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) {
Expand Down

0 comments on commit b5fe27c

Please sign in to comment.