Skip to content

Commit 7c6e391

Browse files
maclover7rvagg
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 fa6f808 commit 7c6e391

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
@@ -82,9 +82,6 @@ const emitDestroyNative = emitHookFactory(destroy_symbol, 'emitDestroyNative');
8282
const emitPromiseResolveNative =
8383
emitHookFactory(promise_resolve_symbol, 'emitPromiseResolveNative');
8484

85-
// TODO(refack): move to node-config.cc
86-
const abort_regex = /^--abort[_-]on[_-]uncaught[_-]exception$/;
87-
8885
// Setup the callbacks that node::AsyncWrap will call when there are hooks to
8986
// process. They use the same functions as the JS embedder API. These callbacks
9087
// are setup immediately to prevent async_wrap.setupHooks() from being hijacked
@@ -104,7 +101,7 @@ function fatalError(e) {
104101
Error.captureStackTrace(o, fatalError);
105102
process._rawDebug(o.stack);
106103
}
107-
if (process.execArgv.some((e) => abort_regex.test(e))) {
104+
if (process.binding('config').shouldAbortOnUncaughtException) {
108105
process.abort();
109106
}
110107
process.exit(1);

src/node_config.cc

+3
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ static void InitConfig(Local<Object> target,
8585
if (config_expose_http2)
8686
READONLY_BOOLEAN_PROPERTY("exposeHTTP2");
8787

88+
if (env->abort_on_uncaught_exception())
89+
READONLY_BOOLEAN_PROPERTY("shouldAbortOnUncaughtException");
90+
8891
READONLY_PROPERTY(target,
8992
"bits",
9093
Number::New(env->isolate(), 8 * sizeof(intptr_t)));

0 commit comments

Comments
 (0)