Skip to content

Commit 11b3e47

Browse files
legendecasUlisesGascon
authored andcommitted
src: create per isolate proxy env template
PR-URL: #48655 Backport-PR-URL: #51239 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
1 parent d00412a commit 11b3e47

File tree

4 files changed

+7
-4
lines changed

4 files changed

+7
-4
lines changed

src/env.cc

+1
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,7 @@ void IsolateData::CreateProperties() {
504504
binding::CreateInternalBindingTemplates(this);
505505

506506
contextify::ContextifyContext::InitializeGlobalTemplates(this);
507+
CreateEnvProxyTemplate(this);
507508
}
508509

509510
constexpr uint16_t kDefaultCppGCEmebdderID = 0x90de;

src/node_env_var.cc

+2-1
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,8 @@ static void EnvDefiner(Local<Name> property,
456456
}
457457
}
458458

459-
void CreateEnvProxyTemplate(Isolate* isolate, IsolateData* isolate_data) {
459+
void CreateEnvProxyTemplate(IsolateData* isolate_data) {
460+
Isolate* isolate = isolate_data->isolate();
460461
HandleScope scope(isolate);
461462
if (!isolate_data->env_proxy_template().IsEmpty()) return;
462463
Local<FunctionTemplate> env_proxy_ctor_template =

src/node_process.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class MemoryTracker;
1515
class ExternalReferenceRegistry;
1616
class Realm;
1717

18-
void CreateEnvProxyTemplate(v8::Isolate* isolate, IsolateData* isolate_data);
18+
void CreateEnvProxyTemplate(IsolateData* isolate_data);
1919

2020
// Most of the time, it's best to use `console.error` to write
2121
// to the process.stderr stream. However, in some cases, such as

src/node_realm.cc

+3-2
Original file line numberDiff line numberDiff line change
@@ -344,10 +344,11 @@ MaybeLocal<Value> PrincipalRealm::BootstrapRealm() {
344344
return MaybeLocal<Value>();
345345
}
346346

347+
// Setup process.env proxy.
347348
Local<String> env_string = FIXED_ONE_BYTE_STRING(isolate_, "env");
348349
Local<Object> env_proxy;
349-
CreateEnvProxyTemplate(isolate_, env_->isolate_data());
350-
if (!env_->env_proxy_template()->NewInstance(context()).ToLocal(&env_proxy) ||
350+
if (!isolate_data()->env_proxy_template()->NewInstance(context()).ToLocal(
351+
&env_proxy) ||
351352
process_object()->Set(context(), env_string, env_proxy).IsNothing()) {
352353
return MaybeLocal<Value>();
353354
}

0 commit comments

Comments
 (0)