Skip to content

Commit 2d61b9e

Browse files
maclover7MylesBorins
authored andcommitted
lib, src: use process.config instead of regex
Is safer to use a `process.binding(config)` defined boolean, than to regex on `process.execArgv`. Also, this better falls in line with the conventions of checking flags passed to the executable. PR-URL: #17814 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent fe1f67f commit 2d61b9e

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

lib/internal/async_hooks.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,6 @@ const emitDestroyNative = emitHookFactory(destroy_symbol, 'emitDestroyNative');
7575
const emitPromiseResolveNative =
7676
emitHookFactory(promise_resolve_symbol, 'emitPromiseResolveNative');
7777

78-
// TODO(refack): move to node-config.cc
79-
const abort_regex = /^--abort[_-]on[_-]uncaught[_-]exception$/;
80-
8178
// Setup the callbacks that node::AsyncWrap will call when there are hooks to
8279
// process. They use the same functions as the JS embedder API. These callbacks
8380
// are setup immediately to prevent async_wrap.setupHooks() from being hijacked
@@ -97,7 +94,7 @@ function fatalError(e) {
9794
Error.captureStackTrace(o, fatalError);
9895
process._rawDebug(o.stack);
9996
}
100-
if (process.execArgv.some((e) => abort_regex.test(e))) {
97+
if (process.binding('config').shouldAbortOnUncaughtException) {
10198
process.abort();
10299
}
103100
process.exit(1);

src/node_config.cc

+3
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ static void InitConfig(Local<Object> target,
8888
if (config_expose_internals)
8989
READONLY_BOOLEAN_PROPERTY("exposeInternals");
9090

91+
if (env->abort_on_uncaught_exception())
92+
READONLY_BOOLEAN_PROPERTY("shouldAbortOnUncaughtException");
93+
9194
READONLY_PROPERTY(target,
9295
"bits",
9396
Number::New(env->isolate(), 8 * sizeof(intptr_t)));

0 commit comments

Comments
 (0)