diff --git a/lib/internal/async_hooks.js b/lib/internal/async_hooks.js index d382fe36e1847f..165d44b7022289 100644 --- a/lib/internal/async_hooks.js +++ b/lib/internal/async_hooks.js @@ -4,6 +4,11 @@ const { ERR_ASYNC_TYPE, ERR_INVALID_ASYNC_ID } = require('internal/errors').codes; + +const { getOptionValue } = require('internal/options'); +const shouldAbortOnUncaughtException = + getOptionValue('--abort-on-uncaught-exception'); + const async_wrap = internalBinding('async_wrap'); /* async_hook_fields is a Uint32Array wrapping the uint32_t array of * Environment::AsyncHooks::fields_[]. Each index tracks the number of active @@ -107,7 +112,7 @@ function fatalError(e) { Error.captureStackTrace(o, fatalError); process._rawDebug(o.stack); } - if (internalBinding('config').shouldAbortOnUncaughtException) { + if (shouldAbortOnUncaughtException) { process.abort(); } process.exit(1); diff --git a/lib/internal/policy/manifest.js b/lib/internal/policy/manifest.js index d0d3431b546073..67b6d7b9d9b6c5 100644 --- a/lib/internal/policy/manifest.js +++ b/lib/internal/policy/manifest.js @@ -20,7 +20,9 @@ const { entries } = Object; const kIntegrities = new SafeWeakMap(); const kReactions = new SafeWeakMap(); const kRelativeURLStringPattern = /^\.{0,2}\//; -const { shouldAbortOnUncaughtException } = internalBinding('config'); +const { getOptionValue } = require('internal/options'); +const shouldAbortOnUncaughtException = + getOptionValue('--abort-on-uncaught-exception'); const { abort, exit, _rawDebug } = process; function REACTION_THROW(error) { diff --git a/src/node_config.cc b/src/node_config.cc index bac64c778da44b..45233eea129e99 100644 --- a/src/node_config.cc +++ b/src/node_config.cc @@ -95,9 +95,6 @@ static void Initialize(Local target, if (env->options()->expose_internals) READONLY_TRUE_PROPERTY(target, "exposeInternals"); - if (env->abort_on_uncaught_exception()) - READONLY_TRUE_PROPERTY(target, "shouldAbortOnUncaughtException"); - READONLY_PROPERTY(target, "bits", Number::New(env->isolate(), 8 * sizeof(intptr_t))); diff --git a/src/node_options.cc b/src/node_options.cc index cbedb966aa2cd9..d163d73f2246aa 100644 --- a/src/node_options.cc +++ b/src/node_options.cc @@ -522,7 +522,14 @@ void GetOptions(const FunctionCallbackInfo& args) { switch (option_info.type) { case kNoOp: case kV8Option: - value = Undefined(isolate); + // Special case for --abort-on-uncaught-exception which is also + // respected by Node.js internals + if (item.first == "--abort-on-uncaught-exception") { + value = Boolean::New( + isolate, original_per_env->abort_on_uncaught_exception); + } else { + value = Undefined(isolate); + } break; case kBoolean: value = Boolean::New(isolate, *parser.Lookup(field, opts));