Skip to content

Commit ed986f9

Browse files
committed
fixup! fixup! fixup! fixup! fixup! src: make BuiltinLoader threadsafe and non-global
1 parent 93e411a commit ed986f9

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/api/environment.cc

+6-1
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,12 @@ Maybe<bool> InitializePrimordials(Local<Context> context) {
714714
"internal/per_context/messageport",
715715
nullptr};
716716

717-
auto builtin_loader = builtins::BuiltinLoader::Create();
717+
// We do not have access to a per-Environment BuiltinLoader instance
718+
// at this point, because this code runs before an Environment exists
719+
// in the first place. However, creating BuiltinLoader instances is
720+
// relatively cheap and all the scripts that we may want to run at
721+
// startup are always present in it.
722+
thread_local auto builtin_loader = builtins::BuiltinLoader::Create();
718723
for (const char** module = context_files; *module != nullptr; module++) {
719724
Local<Value> arguments[] = {exports, primordials};
720725
if (builtin_loader

src/node_builtins.cc

-1
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,6 @@ void BuiltinLoader::GetBuiltinCategories(
563563
Local<Context> context = env->context();
564564
Local<Object> result = Object::New(isolate);
565565

566-
// Copy from the per-process categories
567566
std::set<std::string> cannot_be_required =
568567
env->builtin_loader()->GetCannotBeRequired();
569568
std::set<std::string> can_be_required =

0 commit comments

Comments
 (0)