Skip to content

Commit 9c482b8

Browse files
committed
chore: safe global registry handling
1 parent 8b78f90 commit 9c482b8

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

NativeScript/runtime/ModuleInternalCallbacks.mm

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,12 @@ static bool IsNodeBuiltinModule(const std::string& moduleName) {
391391
return v8::MaybeLocal<v8::Module>();
392392
}
393393

394-
// Store in registry and return
394+
// Store in registry and return - with safe Global handle management
395+
auto it = g_moduleRegistry.find(absPath);
396+
if (it != g_moduleRegistry.end()) {
397+
// Clear the existing Global handle before replacing it
398+
it->second.Reset();
399+
}
395400
g_moduleRegistry[absPath].Reset(isolate, jsonModule);
396401
return v8::MaybeLocal<v8::Module>(jsonModule);
397402
}

0 commit comments

Comments
 (0)