Skip to content

Commit b06f2fa

Browse files
joyeecheungaddaleax
authored andcommitted
lib: use internal/options to query --abort-on-uncaught-exception
Instead of using `internalBinding('config').shouldAbortOnUncaughtException`. Also removes that property from the binding. PR-URL: #25862 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent ef9139e commit b06f2fa

File tree

4 files changed

+17
-6
lines changed

4 files changed

+17
-6
lines changed

lib/internal/async_hooks.js

+6-1
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

+3-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ const { entries } = Object;
2020
const kIntegrities = new SafeWeakMap();
2121
const kReactions = new SafeWeakMap();
2222
const kRelativeURLStringPattern = /^\.{0,2}\//;
23-
const { shouldAbortOnUncaughtException } = internalBinding('config');
23+
const { getOptionValue } = require('internal/options');
24+
const shouldAbortOnUncaughtException =
25+
getOptionValue('--abort-on-uncaught-exception');
2426
const { abort, exit, _rawDebug } = process;
2527

2628
function REACTION_THROW(error) {

src/node_config.cc

-3
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,6 @@ static void Initialize(Local<Object> target,
9595
if (env->options()->expose_internals)
9696
READONLY_TRUE_PROPERTY(target, "exposeInternals");
9797

98-
if (env->abort_on_uncaught_exception())
99-
READONLY_TRUE_PROPERTY(target, "shouldAbortOnUncaughtException");
100-
10198
READONLY_PROPERTY(target,
10299
"bits",
103100
Number::New(env->isolate(), 8 * sizeof(intptr_t)));

src/node_options.cc

+8-1
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,14 @@ void GetOptions(const FunctionCallbackInfo<Value>& args) {
522522
switch (option_info.type) {
523523
case kNoOp:
524524
case kV8Option:
525-
value = Undefined(isolate);
525+
// Special case for --abort-on-uncaught-exception which is also
526+
// respected by Node.js internals
527+
if (item.first == "--abort-on-uncaught-exception") {
528+
value = Boolean::New(
529+
isolate, original_per_env->abort_on_uncaught_exception);
530+
} else {
531+
value = Undefined(isolate);
532+
}
526533
break;
527534
case kBoolean:
528535
value = Boolean::New(isolate, *parser.Lookup<bool>(field, opts));

0 commit comments

Comments
 (0)