diff --git a/Source/JavaScriptCore/runtime/JSMicrotask.cpp b/Source/JavaScriptCore/runtime/JSMicrotask.cpp index 2afe45a3d9f43..622d5e8cbb198 100644 --- a/Source/JavaScriptCore/runtime/JSMicrotask.cpp +++ b/Source/JavaScriptCore/runtime/JSMicrotask.cpp @@ -861,6 +861,15 @@ static void moduleRegistryModuleSettled(JSGlobalObject* globalObject, VM& vm, st auto* entry = uncheckedDowncast(arguments[2]); auto* modulePromise = uncheckedDowncast(arguments[0]); auto status = static_cast(payload); +#if USE(BUN_JSC_ADDITIONS) + // hostLoadImportedModule's synchronous re-entry path may have already + // called fetchComplete() and fulfilled modulePromise inline while a + // synchronous loadModule was active, leaving this queued copy redundant. + // The inline path creates its own module record; the one we'd provide + // here is a duplicate parse of the same source that nothing references. + if (modulePromise->status() != JSPromise::Status::Pending) + return; +#endif if (status == JSPromise::Status::Fulfilled) { auto* moduleRecord = downcast(arguments[1]); entry->fetchComplete(globalObject, moduleRecord);