summaryrefslogtreecommitdiff
path: root/src/node_env_var.cc
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2019-11-12 18:33:37 +0000
committerDaniel Bevenius <daniel.bevenius@gmail.com>2019-11-18 06:16:25 +0100
commit850f38125c17624c8950291c273d759e74d4b0ea (patch)
tree61980f704050c2cd3d689c815504287f914c9dbb /src/node_env_var.cc
parent3e2b68aff3a4b8c065ddb561122b18817201f524 (diff)
downloadandroid-node-v8-850f38125c17624c8950291c273d759e74d4b0ea.tar.gz
android-node-v8-850f38125c17624c8950291c273d759e74d4b0ea.tar.bz2
android-node-v8-850f38125c17624c8950291c273d759e74d4b0ea.zip
src: enhance feature access `CHECK`s during bootstrap
This adds `CHECK`s verifying that bootstrapping has finished before environment variables are accessed or handles/requests are created. The latter complements a pair of existent checks, but fails earlier and thus gives information about the call site, effectively addressing the TODO comment there. PR-URL: https://github.com/nodejs/node/pull/30452 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src/node_env_var.cc')
-rw-r--r--src/node_env_var.cc5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/node_env_var.cc b/src/node_env_var.cc
index 9d229ccf4e..40c0515a3d 100644
--- a/src/node_env_var.cc
+++ b/src/node_env_var.cc
@@ -272,6 +272,7 @@ Maybe<bool> KVStore::AssignFromObject(Local<Context> context,
static void EnvGetter(Local<Name> property,
const PropertyCallbackInfo<Value>& info) {
Environment* env = Environment::GetCurrent(info);
+ CHECK(env->has_run_bootstrapping_code());
if (property->IsSymbol()) {
return info.GetReturnValue().SetUndefined();
}
@@ -287,6 +288,7 @@ static void EnvSetter(Local<Name> property,
Local<Value> value,
const PropertyCallbackInfo<Value>& info) {
Environment* env = Environment::GetCurrent(info);
+ CHECK(env->has_run_bootstrapping_code());
// calling env->EmitProcessEnvWarning() sets a variable indicating that
// warnings have been emitted. It should be called last after other
// conditions leading to a warning have been met.
@@ -320,6 +322,7 @@ static void EnvSetter(Local<Name> property,
static void EnvQuery(Local<Name> property,
const PropertyCallbackInfo<Integer>& info) {
Environment* env = Environment::GetCurrent(info);
+ CHECK(env->has_run_bootstrapping_code());
if (property->IsString()) {
int32_t rc = env->env_vars()->Query(env->isolate(), property.As<String>());
if (rc != -1) info.GetReturnValue().Set(rc);
@@ -329,6 +332,7 @@ static void EnvQuery(Local<Name> property,
static void EnvDeleter(Local<Name> property,
const PropertyCallbackInfo<Boolean>& info) {
Environment* env = Environment::GetCurrent(info);
+ CHECK(env->has_run_bootstrapping_code());
if (property->IsString()) {
env->env_vars()->Delete(env->isolate(), property.As<String>());
}
@@ -340,6 +344,7 @@ static void EnvDeleter(Local<Name> property,
static void EnvEnumerator(const PropertyCallbackInfo<Array>& info) {
Environment* env = Environment::GetCurrent(info);
+ CHECK(env->has_run_bootstrapping_code());
info.GetReturnValue().Set(
env->env_vars()->Enumerate(env->isolate()));