Skip to content

Commit c9475ec

Browse files
committed
lib: use internal/options to query --abort-on-uncaught-exception
Instead of using `internalBinding('config').shouldAbortOnUncaughtException`. Also removes that property from the binding.
1 parent b4e670d commit c9475ec

File tree

4 files changed

+17
-6
lines changed

4 files changed

+17
-6
lines changed

lib/internal/async_hooks.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ const {
44
ERR_ASYNC_TYPE,
55
ERR_INVALID_ASYNC_ID
66
} = require('internal/errors').codes;
7+
8+
const { getOptionValue } = require('internal/options');
9+
const shouldAbortOnUncaughtException =
10+
getOptionValue('--abort-on-uncaught-exception');
11+
712
const async_wrap = internalBinding('async_wrap');
813
/* async_hook_fields is a Uint32Array wrapping the uint32_t array of
914
* Environment::AsyncHooks::fields_[]. Each index tracks the number of active
@@ -107,7 +112,7 @@ function fatalError(e) {
107112
Error.captureStackTrace(o, fatalError);
108113
process._rawDebug(o.stack);
109114
}
110-
if (internalBinding('config').shouldAbortOnUncaughtException) {
115+
if (shouldAbortOnUncaughtException) {
111116
process.abort();
112117
}
113118
process.exit(1);

lib/internal/policy/manifest.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ const { entries } = Object;
2525
const kIntegrities = new SafeWeakMap();
2626
const kReactions = new SafeWeakMap();
2727
const kRelativeURLStringPattern = /^\.{0,2}\//;
28-
const { shouldAbortOnUncaughtException } = internalBinding('config');
28+
const { getOptionValue } = require('internal/options');
29+
const shouldAbortOnUncaughtException =
30+
getOptionValue('--abort-on-uncaught-exception');
2931
const { abort, exit, _rawDebug } = process;
3032

3133
function REACTION_THROW(error) {

src/node_config.cc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,6 @@ static void Initialize(Local<Object> target,
6969
READONLY_FALSE_PROPERTY(target, "hasInspector");
7070
#endif
7171

72-
if (env->abort_on_uncaught_exception())
73-
READONLY_TRUE_PROPERTY(target, "shouldAbortOnUncaughtException");
74-
7572
READONLY_PROPERTY(target,
7673
"bits",
7774
Number::New(env->isolate(), 8 * sizeof(intptr_t)));

src/node_options.cc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,14 @@ void GetOptions(const FunctionCallbackInfo<Value>& args) {
540540
switch (option_info.type) {
541541
case kNoOp:
542542
case kV8Option:
543-
value = Undefined(isolate);
543+
// Special case for --abort-on-uncaught-exception which is also
544+
// respected by Node.js internals
545+
if (item.first == "--abort-on-uncaught-exception") {
546+
value = Boolean::New(
547+
isolate, original_per_env->abort_on_uncaught_exception);
548+
} else {
549+
value = Undefined(isolate);
550+
}
544551
break;
545552
case kBoolean:
546553
value = Boolean::New(isolate, *parser.Lookup<bool>(field, opts));

0 commit comments

Comments
 (0)