diff --git a/src/node_env_var.cc b/src/node_env_var.cc index fe0896aaf50900..307153c0e3781b 100644 --- a/src/node_env_var.cc +++ b/src/node_env_var.cc @@ -436,15 +436,14 @@ static Intercepted EnvGetter(Local property, MaybeLocal value_string = env->env_vars()->Get(env->isolate(), property.As()); - bool has_env = !value_string.IsEmpty(); TraceEnvVar(env, "get", property.As()); - if (has_env) { - // ToLocalChecked here is ok since we check IsEmpty above. - info.GetReturnValue().Set(value_string.ToLocalChecked()); - return Intercepted::kYes; + Local ret; + if (!value_string.ToLocal(&ret)) { + return Intercepted::kNo; } - return Intercepted::kNo; + info.GetReturnValue().Set(ret); + return Intercepted::kYes; } static Intercepted EnvSetter(Local property,