Skip to content
Merged
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Source/JavaScriptCore/runtime/JSModuleLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1060,7 +1060,17 @@ void JSModuleLoader::finishLoadingImportedModule(JSGlobalObject* globalObject, c
auto scope = DECLARE_THROW_SCOPE(vm);

// 1. If result is a normal completion, then
#if USE(BUN_JSC_ADDITIONS)
// hostLoadImportedModule() relies on the realm's [[LoadedModules]] holding only what the registry holds. removeEntry()
// and clearAll() take a module out of both, and a load of it that was in flight then must not put it back into one.
auto isRegistered = [&](AbstractModuleRecord* record) {
ModuleRegistryEntry* entry = getRegisteredMayBeNull(record->moduleKey(), moduleRequest.type());
return entry && entry->record() == record;
};
if (auto* resultRecord = std::get_if<AbstractModuleRecord*>(&result); resultRecord && (!referrer.isRealm() || isRegistered(*resultRecord))) {
Comment thread
dylan-conway marked this conversation as resolved.
Resolved
Comment thread
dylan-conway marked this conversation as resolved.
Resolved
#else
if (auto* resultRecord = std::get_if<AbstractModuleRecord*>(&result)) {
#endif
JSCell* owner = nullptr;

auto& loadedModules = [&] -> ModuleMap<AbstractModuleRecord::LoadedModuleRequest> & {
Expand Down
Loading