Skip to content

Commit

Permalink
lib, src: use process.config instead of regex
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
maclover7 authored and MylesBorins committed May 22, 2018
1 parent b07b9f2 commit 524efb9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
5 changes: 1 addition & 4 deletions lib/internal/async_hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,6 @@ const emitDestroyNative = emitHookFactory(destroy_symbol, 'emitDestroyNative');
const emitPromiseResolveNative =
emitHookFactory(promise_resolve_symbol, 'emitPromiseResolveNative');

// TODO(refack): move to node-config.cc
const abort_regex = /^--abort[_-]on[_-]uncaught[_-]exception$/;

// Setup the callbacks that node::AsyncWrap will call when there are hooks to
// process. They use the same functions as the JS embedder API. These callbacks
// are setup immediately to prevent async_wrap.setupHooks() from being hijacked
Expand All @@ -104,7 +101,7 @@ function fatalError(e) {
Error.captureStackTrace(o, fatalError);
process._rawDebug(o.stack);
}
if (process.execArgv.some((e) => abort_regex.test(e))) {
if (process.binding('config').shouldAbortOnUncaughtException) {
process.abort();
}
process.exit(1);
Expand Down
3 changes: 3 additions & 0 deletions src/node_config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ static void InitConfig(Local<Object> target,
if (config_expose_http2)
READONLY_BOOLEAN_PROPERTY("exposeHTTP2");

if (env->abort_on_uncaught_exception())
READONLY_BOOLEAN_PROPERTY("shouldAbortOnUncaughtException");

READONLY_PROPERTY(target,
"bits",
Number::New(env->isolate(), 8 * sizeof(intptr_t)));
Expand Down

0 comments on commit 524efb9

Please sign in to comment.