src: forbid access to CLI options before bootstrapping is done · nodejs/node@63e7cc7 (original) (raw)
2 files changed
lines changed
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -5,10 +5,6 @@ const { | ||
5 | 5 | ERR_INVALID_ASYNC_ID |
6 | 6 | } = require('internal/errors').codes; |
7 | 7 | |
8 | -const { getOptionValue } = require('internal/options'); | |
9 | -const shouldAbortOnUncaughtException = | |
10 | -getOptionValue('--abort-on-uncaught-exception'); | |
11 | - | |
12 | 8 | const async_wrap = internalBinding('async_wrap'); |
13 | 9 | /* async_hook_fields is a Uint32Array wrapping the uint32_t array of |
14 | 10 | * Environment::AsyncHooks::fields_[]. Each index tracks the number of active |
@@ -102,7 +98,9 @@ function fatalError(e) { | ||
102 | 98 | Error.captureStackTrace(o, fatalError); |
103 | 99 | process._rawDebug(o.stack); |
104 | 100 | } |
105 | -if (shouldAbortOnUncaughtException) { | |
101 | + | |
102 | +const { getOptionValue } = require('internal/options'); | |
103 | +if (getOptionValue('--abort-on-uncaught-exception')) { | |
106 | 104 | process.abort(); |
107 | 105 | } |
108 | 106 | process.exit(1); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -548,6 +548,12 @@ HostPort SplitHostPort(const std::string& arg, | ||
548 | 548 | void GetOptions(const FunctionCallbackInfo& args) { |
549 | 549 | Mutex::ScopedLock lock(per_process::cli_options_mutex); |
550 | 550 | Environment* env = Environment::GetCurrent(args); |
551 | +if (!env->has_run_bootstrapping_code()) { | |
552 | +// No code because this is an assertion. | |
553 | +return env->ThrowError( | |
554 | +"Should not query options before bootstrapping is done"); | |
555 | + } | |
556 | + | |
551 | 557 | Isolate* isolate = env->isolate(); |
552 | 558 | Local context = env->context(); |
553 | 559 |