mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
src: forbid access to CLI options before bootstrapping is done
PR-URL: https://github.com/nodejs/node/pull/26476 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Richard Lau <riclau@uk.ibm.com>
This commit is contained in:
parent
4e9dc31817
commit
d57d09905e
@ -5,10 +5,6 @@ const {
|
||||
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
|
||||
@ -112,7 +108,9 @@ function fatalError(e) {
|
||||
Error.captureStackTrace(o, fatalError);
|
||||
process._rawDebug(o.stack);
|
||||
}
|
||||
if (shouldAbortOnUncaughtException) {
|
||||
|
||||
const { getOptionValue } = require('internal/options');
|
||||
if (getOptionValue('--abort-on-uncaught-exception')) {
|
||||
process.abort();
|
||||
}
|
||||
process.exit(1);
|
||||
|
@ -564,6 +564,12 @@ HostPort SplitHostPort(const std::string& arg,
|
||||
void GetOptions(const FunctionCallbackInfo<Value>& args) {
|
||||
Mutex::ScopedLock lock(per_process::cli_options_mutex);
|
||||
Environment* env = Environment::GetCurrent(args);
|
||||
if (!env->has_run_bootstrapping_code()) {
|
||||
// No code because this is an assertion.
|
||||
return env->ThrowError(
|
||||
"Should not query options before bootstrapping is done");
|
||||
}
|
||||
|
||||
Isolate* isolate = env->isolate();
|
||||
Local<Context> context = env->context();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user