Skip to content

Commit b5fe27c

Browse files
joyeecheungrvagg
authored andcommitted
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: #26061 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Minwoo Jung <[email protected]> Reviewed-By: Gus Caplan <[email protected]>
1 parent 0c4353a commit b5fe27c

File tree

1 file changed

+14
-18
lines changed

1 file changed

+14
-18
lines changed

lib/internal/bootstrap/node.js

+14-18
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

@@ -303,6 +285,20 @@ Object.defineProperty(process, 'features', {
303285
}
304286
});
305287

288+
{
289+
const {
290+
fatalException,
291+
setUncaughtExceptionCaptureCallback,
292+
hasUncaughtExceptionCaptureCallback
293+
} = NativeModule.require('internal/process/execution');
294+
295+
process._fatalException = fatalException;
296+
process.setUncaughtExceptionCaptureCallback =
297+
setUncaughtExceptionCaptureCallback;
298+
process.hasUncaughtExceptionCaptureCallback =
299+
hasUncaughtExceptionCaptureCallback;
300+
}
301+
306302
// User-facing NODE_V8_COVERAGE environment variable that writes
307303
// ScriptCoverage to a specified file.
308304
if (process.env.NODE_V8_COVERAGE) {

0 commit comments

Comments
 (0)