Skip to content

Commit 0c98f19

Browse files
committed
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.
1 parent 006e78c commit 0c98f19

File tree

1 file changed

+14
-18
lines changed

1 file changed

+14
-18
lines changed

lib/internal/bootstrap/node.js

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -46,24 +46,6 @@ setupTraceCategoryState();
4646

4747
setupProcessObject();
4848

49-
// TODO(joyeecheung): this does not have to done so early, any fatal errors
50-
// thrown before user code execution should simply crash the process
51-
// and we do not care about any clean up at that point. We don't care
52-
// about emitting any events if the process crash upon bootstrap either.
53-
{
54-
const {
55-
fatalException,
56-
setUncaughtExceptionCaptureCallback,
57-
hasUncaughtExceptionCaptureCallback
58-
} = NativeModule.require('internal/process/execution');
59-
60-
process._fatalException = fatalException;
61-
process.setUncaughtExceptionCaptureCallback =
62-
setUncaughtExceptionCaptureCallback;
63-
process.hasUncaughtExceptionCaptureCallback =
64-
hasUncaughtExceptionCaptureCallback;
65-
}
66-
6749
setupGlobalProxy();
6850
setupBuffer();
6951

@@ -265,6 +247,20 @@ Object.defineProperty(process, 'features', {
265247
}
266248
});
267249

250+
{
251+
const {
252+
fatalException,
253+
setUncaughtExceptionCaptureCallback,
254+
hasUncaughtExceptionCaptureCallback
255+
} = NativeModule.require('internal/process/execution');
256+
257+
process._fatalException = fatalException;
258+
process.setUncaughtExceptionCaptureCallback =
259+
setUncaughtExceptionCaptureCallback;
260+
process.hasUncaughtExceptionCaptureCallback =
261+
hasUncaughtExceptionCaptureCallback;
262+
}
263+
268264
// User-facing NODE_V8_COVERAGE environment variable that writes
269265
// ScriptCoverage to a specified file.
270266
if (process.env.NODE_V8_COVERAGE) {

0 commit comments

Comments
 (0)