Skip to content

Commit

Permalink
lib: use internal/options to query --abort-on-uncaught-exception
Browse files Browse the repository at this point in the history
Instead of using
`internalBinding('config').shouldAbortOnUncaughtException`.
Also removes that property from the binding.

PR-URL: #25862
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
  • Loading branch information
joyeecheung authored and addaleax committed Feb 8, 2019
1 parent ef9139e commit b06f2fa
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
7 changes: 6 additions & 1 deletion lib/internal/async_hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion lib/internal/policy/manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 0 additions & 3 deletions src/node_config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,6 @@ static void Initialize(Local<Object> 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)));
Expand Down
9 changes: 8 additions & 1 deletion src/node_options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,14 @@ void GetOptions(const FunctionCallbackInfo<Value>& 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<bool>(field, opts));
Expand Down

0 comments on commit b06f2fa

Please sign in to comment.