diff --git a/lib/internal/async_hooks.js b/lib/internal/async_hooks.js index 4bd5f3191b6e4a..035dd0634daf6a 100644 --- a/lib/internal/async_hooks.js +++ b/lib/internal/async_hooks.js @@ -75,9 +75,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 @@ -97,7 +94,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); diff --git a/src/node_config.cc b/src/node_config.cc index bf46444cabd107..2e9ad2ed134822 100644 --- a/src/node_config.cc +++ b/src/node_config.cc @@ -88,6 +88,9 @@ static void InitConfig(Local target, if (config_expose_internals) READONLY_BOOLEAN_PROPERTY("exposeInternals"); + if (env->abort_on_uncaught_exception()) + READONLY_BOOLEAN_PROPERTY("shouldAbortOnUncaughtException"); + READONLY_PROPERTY(target, "bits", Number::New(env->isolate(), 8 * sizeof(intptr_t)));