diff options
author | Benjamin <bencoe@gmail.com> | 2019-01-21 08:53:19 +0300 |
---|---|---|
committer | Benjamin <bencoe@gmail.com> | 2019-01-21 21:30:04 +0300 |
commit | 0b50972e6cf4a135a1eadd14f3e731d8a14839f1 (patch) | |
tree | 8375b802e7f4b5373c2e328bb62dc6fd21374744 /src/node_env_var.cc | |
parent | f698386c7e988ef45027a75b2ff988899ee2af1d (diff) |
process: check env->EmitProcessEnvWarning() last
Calling env->EmitProcessEnvWarning() prevents additional warnings
from being set it should therefore be called only if a warning will
emit.
PR-URL: https://github.com/nodejs/node/pull/25575
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Diffstat (limited to 'src/node_env_var.cc')
-rw-r--r-- | src/node_env_var.cc | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/node_env_var.cc b/src/node_env_var.cc index 63cba55ab56..60582d7a31c 100644 --- a/src/node_env_var.cc +++ b/src/node_env_var.cc @@ -72,8 +72,12 @@ static void EnvSetter(Local<Name> property, Local<Value> value, const PropertyCallbackInfo<Value>& info) { Environment* env = Environment::GetCurrent(info); - if (env->options()->pending_deprecation && env->EmitProcessEnvWarning() && - !value->IsString() && !value->IsNumber() && !value->IsBoolean()) { + // 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. + if (env->options()->pending_deprecation && !value->IsString() && + !value->IsNumber() && !value->IsBoolean() && + env->EmitProcessEnvWarning()) { if (ProcessEmitDeprecationWarning( env, "Assigning any value other than a string, number, or boolean to a " |