Run callback passed to napi_module_register after dlopen returns instead of during call (#20478)

This commit is contained in:
190n
2025-07-24 11:46:56 -07:00
committed by GitHub
parent 9fa8ae9a40
commit 03dfd7d96b
9 changed files with 132 additions and 28 deletions

View File

@@ -535,6 +535,15 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionDlopen, (JSC::JSGlobalObject * globalOb
#endif
if (callCountAtStart != globalObject->napiModuleRegisterCallCount) {
// Module self-registered via static constructor
if (globalObject->m_pendingNapiModule) {
// Execute the stored registration function now that dlopen has completed
Napi::executePendingNapiModule(globalObject);
// Clear the pending module
globalObject->m_pendingNapiModule = {};
}
JSValue resultValue = globalObject->m_pendingNapiModuleAndExports[0].get();
globalObject->napiModuleRegisterCallCount = 0;
globalObject->m_pendingNapiModuleAndExports[0].clear();