Skip to content

[JSC] ReferenceError when multiple modules are simultaneously importing a module containing a top-level await#24122

Closed
shvaikalesh wants to merge 1 commit intoWebKit:mainfrom
shvaikalesh:eng/JSC-ReferenceError-when-multiple-modules-are-simultaneously-importing-a-module-containing-a-top-level-await
Closed

[JSC] ReferenceError when multiple modules are simultaneously importing a module containing a top-level await#24122
shvaikalesh wants to merge 1 commit intoWebKit:mainfrom
shvaikalesh:eng/JSC-ReferenceError-when-multiple-modules-are-simultaneously-importing-a-module-containing-a-top-level-await

Conversation

@shvaikalesh
Copy link
Member

@shvaikalesh shvaikalesh commented Feb 9, 2024

cf39202

[JSC] ReferenceError when multiple modules are simultaneously importing a module containing a top-level await
https://bugs.webkit.org/show_bug.cgi?id=242740
<rdar://problem/97370038>

Reviewed by NOBODY (OOPS!).

This change completely re-implements module loader to precisely follow the spec steps [1],
resolving multiple issues revolving around importing modules with top-level `await`.

Infinite retry of module fetching & parsing is removed as it's not part of the spec,
nor other browsers behave in the same way.

This patch also rewires the way module loader is hooked into workers / worklets, which became
necessary due to functions like evaluateModule() became always `async`. Along with this,
errors occuring in modules with top-level `await` are now properly reported to the console,
resolving another developers' pain point.

[1]: https://tc39.es/ecma262/#sec-cyclic-module-records

* JSTests/test262/expectations.yaml:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/cors-crossorigin-requests-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/repeated-imports.any-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/repeated-imports.any.sharedworker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/repeated-imports.any.worker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/checkpoint-after-workerglobalscope-onerror-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/checkpoint-after-workerglobalscope-onerror-module-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/evaluation-order-1-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/evaluation-order-1-throw-importScripts.any.sharedworker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/evaluation-order-1-throw-importScripts.any.worker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/evaluation-order-2-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/choice-of-error-2-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/choice-of-error-3-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/crossorigin-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/dynamic-import/blob-url.any-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/dynamic-import/blob-url.any.sharedworker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/dynamic-import/blob-url.any.worker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/dynamic-import/dynamic-imports-fetch-error.sub-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/dynamic-import/dynamic-imports-script-error-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/error-type-2-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/error-type-3-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-error-1-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-error-2-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-error-3-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-error-4-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/instantiation-error-1-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/instantiation-error-2-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/instantiation-error-3-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/instantiation-error-4-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/instantiation-error-5-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/instantiation-error-6-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/instantiation-error-7-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/webappapis/scripting/events/event-handler-processing-algorithm-error/worker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/workers/modules/dedicated-worker-import-blob-url.any-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/workers/modules/dedicated-worker-import-blob-url.any.worker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/workers/modules/dedicated-worker-import-failure-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/workers/modules/dedicated-worker-parse-error-failure-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/workers/modules/shared-worker-import-blob-url.window-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/workers/modules/shared-worker-parse-error-failure-expected.txt:
* Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj:
* Source/JavaScriptCore/builtins/BuiltinNames.h:
* Source/JavaScriptCore/builtins/ModuleLoader.js:
(visibility.PrivateRecursive.ensureModuleMapEntry):
(visibility.PrivateRecursive.hostFetchAndLoadImportedModule):
(visibility.PrivateRecursive.hostLoadImportedModule):
(visibility.PrivateRecursive.fetchDescendantsOfAndLink):
(visibility.PrivateRecursive.innerModuleLoading):
(visibility.PrivateRecursive.moduleLinking):
(visibility.PrivateRecursive.innerModuleLinking):
(visibility.PrivateRecursive.moduleEvaluation):
(visibility.PrivateRecursive.innerModuleEvaluation):
(visibility.PrivateRecursive.async executeAsyncModule):
(linkTimeConstant.gatherAvailableAncestors):
(visibility.PrivateRecursive.asyncModuleExecutionFulfilled):
(linkTimeConstant.asyncModuleExecutionRejected):
(visibility.PrivateRecursive.fetchModule):
(visibility.PrivateRecursive.fetchModuleAndEvaluate):
(visibility.PrivateRecursive.evaluateModule):
(visibility.PrivateRecursive.loadModule):
(visibility.PrivateRecursive.loadModuleAndEvaluate):
(visibility.PrivateRecursive.requestImportModule):
(visibility.PrivateRecursive.dependencyKeysIfEvaluated):
(linkTimeConstant.setStateToMax): Deleted.
(linkTimeConstant.newRegistryEntry): Deleted.
(visibility.PrivateRecursive.ensureRegistered): Deleted.
(linkTimeConstant.forceFulfillPromise): Deleted.
(linkTimeConstant.fulfillFetch): Deleted.
(visibility.PrivateRecursive.requestFetch): Deleted.
(linkTimeConstant.cacheSatisfy): Deleted.
(async linkTimeConstant.cacheSatisfyAndReturn): Deleted.
(visibility.PrivateRecursive.requestSatisfy): Deleted.
(visibility.PrivateRecursive.requestSatisfyUtil): Deleted.
(visibility.PrivateRecursive.link): Deleted.
(visibility.PrivateRecursive.async asyncModuleEvaluation): Deleted.
(visibility.PrivateRecursive.provideFetch): Deleted.
(visibility.PrivateRecursive.async loadModule): Deleted.
(visibility.PrivateRecursive.linkAndEvaluateModule): Deleted.
(visibility.PrivateRecursive.async loadAndEvaluateModule): Deleted.
(visibility.PrivateRecursive.async requestImportModule): Deleted.
* Source/JavaScriptCore/bytecode/BytecodeIntrinsicRegistry.cpp:
(JSC::BytecodeIntrinsicRegistry::BytecodeIntrinsicRegistry):
* Source/JavaScriptCore/bytecode/BytecodeIntrinsicRegistry.h:
* Source/JavaScriptCore/jsc.cpp:
(dumpException):
(runWithOptions):
* Source/JavaScriptCore/parser/Parser.cpp:
(JSC::Parser<LexerType>::parseInner):
* Source/JavaScriptCore/runtime/AbstractModuleRecord.cpp:
(JSC::AbstractModuleRecord::hostResolveImportedModule):
(JSC::AbstractModuleRecord::link):
* Source/JavaScriptCore/runtime/ArrayPrototype.cpp:
(JSC::ArrayPrototype::finishCreation):
* Source/JavaScriptCore/runtime/Completion.cpp:
(JSC::createSymbolForEntryPointModule): Deleted.
(JSC::rejectPromise): Deleted.
(JSC::loadAndEvaluateModule): Deleted.
(JSC::loadModule): Deleted.
(JSC::linkAndEvaluateModule): Deleted.
* Source/JavaScriptCore/runtime/Completion.h:
* Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
* Source/JavaScriptCore/runtime/JSModuleLoader.cpp:
(JSC::JSModuleLoader::finishCreation):
(JSC::createSymbolForEntryPointModule):
(JSC::JSModuleLoader::loadModule):
(JSC::JSModuleLoader::loadModuleAndEvaluate):
(JSC::JSModuleLoader::fetchModule):
(JSC::JSModuleLoader::fetchModuleAndEvaluate):
(JSC::JSModuleLoader::evaluateModule):
(JSC::JSC_DEFINE_HOST_FUNCTION):
(JSC::JSModuleLoader::provideFetch): Deleted.
(JSC::JSModuleLoader::loadAndEvaluateModule): Deleted.
(JSC::JSModuleLoader::linkAndEvaluateModule): Deleted.
* Source/JavaScriptCore/runtime/JSModuleLoader.h:
* Source/JavaScriptCore/runtime/SyntheticModuleRecord.cpp:
(JSC::SyntheticModuleRecord::link):
* Source/JavaScriptCore/runtime/SyntheticModuleRecord.h:
* Source/JavaScriptCore/wasm/js/WebAssemblyModuleRecord.cpp:
(JSC::WebAssemblyModuleRecord::link):
* Source/JavaScriptCore/wasm/js/WebAssemblyModuleRecord.h:
* Source/WebCore/bindings/js/JSExecState.h:
(WebCore::JSExecState::loadModule):
(WebCore::JSExecState::loadModuleAndEvaluate):
(WebCore::JSExecState::fetchModule):
(WebCore::JSExecState::fetchModuleAndEvaluate):
(WebCore::JSExecState::evaluateModule):
(WebCore::JSExecState::linkAndEvaluateModule): Deleted.
* Source/WebCore/bindings/js/ScheduledAction.cpp:
(WebCore::ScheduledAction::execute):
* Source/WebCore/bindings/js/ScriptController.cpp:
(WebCore::ScriptController::loadModuleScriptInWorld):
(WebCore::ScriptController::evaluateModuleScriptInWorld):
(WebCore::ScriptController::evaluateModuleScript):
(WebCore::ScriptController::linkAndEvaluateModuleScriptInWorld): Deleted.
(WebCore::ScriptController::linkAndEvaluateModuleScript): Deleted.
* Source/WebCore/bindings/js/ScriptController.h:
* Source/WebCore/bindings/js/WorkerScriptFetcher.h:
* Source/WebCore/dom/ScriptElement.cpp:
(WebCore::ScriptElement::executeModuleScript):
* Source/WebCore/workers/DedicatedWorkerThread.h:
(WebCore::DedicatedWorkerThread::workerObjectProxy const):
(WebCore::DedicatedWorkerThread::start): Deleted.
* Source/WebCore/workers/WorkerOrWorkletScriptController.cpp:
(WebCore::WorkerOrWorkletScriptController::evaluateAndReportException):
(WebCore::WorkerOrWorkletScriptController::evaluate):
(WebCore::WorkerOrWorkletScriptController::loadModuleAndEvaluate):
(WebCore::WorkerOrWorkletScriptController::fetchWorkletModuleAndEvaluate):
(WebCore::jsValueToModuleKey): Deleted.
(WebCore::WorkerOrWorkletScriptController::loadModuleSynchronously): Deleted.
(WebCore::WorkerOrWorkletScriptController::linkAndEvaluateModule): Deleted.
(WebCore::WorkerOrWorkletScriptController::loadAndEvaluateModule): Deleted.
* Source/WebCore/workers/WorkerOrWorkletScriptController.h:
* Source/WebCore/workers/WorkerOrWorkletThread.cpp:
(WebCore::WorkerOrWorkletThread::workerOrWorkletThread):
* Source/WebCore/workers/WorkerOrWorkletThread.h:
(WebCore::WorkerOrWorkletThread::evaluateScriptIfNecessary):
* Source/WebCore/workers/WorkerThread.cpp:
(WebCore::WorkerThread::evaluateScriptIfNecessary):
* Source/WebCore/workers/WorkerThread.h:
* Source/WebCore/workers/shared/context/SharedWorkerContextManager.cpp:
(WebCore::SharedWorkerContextManager::registerSharedWorkerThread):
* Source/WebCore/worklets/WorkletGlobalScope.cpp:
(WebCore::WorkletGlobalScope::evaluate):
(WebCore::WorkletGlobalScope::fetchAndInvokeScript):

cf39202

Misc iOS, visionOS, tvOS & watchOS macOS Linux Windows
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe ✅ 🛠 win
✅ 🧪 bindings ✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug ❌ 🧪 wpe-wk2 ✅ 🧪 win-tests
✅ 🧪 webkitperl ❌ 🧪 ios-wk2 ✅ 🧪 api-mac loading 🧪 api-wpe
❌ 🧪 ios-wk2-wpt ❌ 🧪 mac-wk1 ✅ 🛠 wpe-cairo
✅ 🛠 🧪 jsc ✅ 🧪 api-ios ❌ 🧪 mac-wk2 ✅ 🛠 gtk
✅ 🛠 🧪 jsc-arm64 ✅ 🛠 vision ❌ 🧪 mac-AS-debug-wk2 ❌ 🧪 gtk-wk2
✅ 🛠 vision-sim ❌ 🧪 mac-wk2-stress ✅ 🧪 api-gtk
✅ 🧪 vision-wk2 ❌ 🧪 mac-intel-wk2 ✅ 🛠 jsc-armv7
✅ 🛠 tv ❌ 🛠 mac-safer-cpp ✅ 🧪 jsc-armv7-tests
✅ 🛠 tv-sim
✅ 🛠 watch
✅ 🛠 watch-sim

@shvaikalesh shvaikalesh requested a review from a team as a code owner February 9, 2024 03:26
@shvaikalesh shvaikalesh self-assigned this Feb 9, 2024
@shvaikalesh shvaikalesh added the JavaScriptCore For bugs in JavaScriptCore, the JS engine used by WebKit, other than kxmlcore issues. label Feb 9, 2024
@shvaikalesh shvaikalesh marked this pull request as draft February 9, 2024 03:42
@TKDev7
Copy link

TKDev7 commented Feb 10, 2024

This is a horrible bug.

@biozal
Copy link

biozal commented Feb 13, 2024

Is there a work around for this until this is fixed? This is causing a lot of issues for a product I'm working on and supporting Safari.

@shvaikalesh
Copy link
Member Author

Is there a work around for this until this is fixed?

The fix proposed in this PR breaks the case of module importing itself. I don't see any other way except for re-implementing the module loader to adhere to the spec (https://tc39.es/ecma262/#cyclic-module-record), which will take some time.

@biozal
Copy link

biozal commented Feb 14, 2024

Is there a work around for this until this is fixed?

The fix proposed in this PR breaks the case of module importing itself. I don't see any other way except for re-implementing the module loader to adhere to the spec (https://tc39.es/ecma262/#cyclic-module-record), which will take some time.

So what do we do then until this is fixed, tell people not to use Safari? I mean this is a pretty big problem for any modern web application.

@mb21
Copy link

mb21 commented Mar 21, 2024

I don't see any other way except for re-implementing the module loader to adhere to the spec, which will take some time.

Would be great if this could be prioritized. A lot of people using modern frameworks like SvelteKit or Astro (that use native ESM modules) are running into this, and it's often very hard to debug, so they don't realize it's this bug.

@shvaikalesh
Copy link
Member Author

Would be great if this could be prioritized. A lot of people using modern frameworks like sveltejs/kit#11601 or withastro/astro#10055 (that use native ESM modules) are running into this, and it's often very hard to debug, so they don't realize it's this bug.

Thank you for linking the issues, it's super important for our internal bookkeeping. Good news is that this issue being worked on, we are rewriting module loader to adhere to the spec, ETA is only a few weeks.

@GauteHaugen
Copy link

@shvaikalesh, Is there an update on this? Also, when this gets merged, what is the usual process/timeline for getting this fix out to end users?

@shvaikalesh shvaikalesh force-pushed the eng/JSC-ReferenceError-when-multiple-modules-are-simultaneously-importing-a-module-containing-a-top-level-await branch from 7aabdfe to aee0d36 Compare May 13, 2024 14:25
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label May 13, 2024
@shvaikalesh shvaikalesh removed the merging-blocked Applied to prevent a change from being merged label May 13, 2024
@shvaikalesh shvaikalesh force-pushed the eng/JSC-ReferenceError-when-multiple-modules-are-simultaneously-importing-a-module-containing-a-top-level-await branch from aee0d36 to a0c5449 Compare May 13, 2024 23:51
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label May 14, 2024
@shvaikalesh shvaikalesh removed the merging-blocked Applied to prevent a change from being merged label May 14, 2024
@shvaikalesh shvaikalesh force-pushed the eng/JSC-ReferenceError-when-multiple-modules-are-simultaneously-importing-a-module-containing-a-top-level-await branch from a0c5449 to 8c637db Compare May 14, 2024 20:33
@shvaikalesh shvaikalesh marked this pull request as ready for review May 14, 2024 20:44
@shvaikalesh shvaikalesh requested review from cdumez and rniwa as code owners May 14, 2024 20:44
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label May 14, 2024
@shvaikalesh shvaikalesh removed the merging-blocked Applied to prevent a change from being merged label May 14, 2024
@shvaikalesh shvaikalesh force-pushed the eng/JSC-ReferenceError-when-multiple-modules-are-simultaneously-importing-a-module-containing-a-top-level-await branch from 8c637db to 3aacdb9 Compare May 14, 2024 21:33
@shvaikalesh shvaikalesh force-pushed the eng/JSC-ReferenceError-when-multiple-modules-are-simultaneously-importing-a-module-containing-a-top-level-await branch from 3aacdb9 to 7f9c271 Compare May 14, 2024 21:51
@shvaikalesh shvaikalesh force-pushed the eng/JSC-ReferenceError-when-multiple-modules-are-simultaneously-importing-a-module-containing-a-top-level-await branch from 8541e4f to 7708e7d Compare October 9, 2024 23:03
@webkit-ews-buildbot
Copy link
Collaborator

Safer C++ Build #909

❌ Found 1 new failure. Please address these issues before landing. See WebKit Guidelines for Safer C++ Programming.
(cc @rniwa)

⚠️ Found 1 fixed file! Please update expectations in Source/[WebKit/WebCore]/SaferCPPExpectations by running the following commands and update your pull request:

  • Tools/Scripts/update-safer-cpp-expectations -p WebCore --NoUncheckedPtrMemberChecker workers/service/context/ServiceWorkerDebuggable.h
  • Tools/Scripts/update-safer-cpp-expectations -p WebCore --UncountedCallArgsChecker bindings/js/JSExecState.h

@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Oct 10, 2024
@webkit-ews-buildbot
Copy link
Collaborator

Safer C++ Build #936

❌ Found 1 new failure. Please address these issues before landing. See WebKit Guidelines for Safer C++ Programming.
(cc @rniwa)

⚠️ Found 1 fixed file! Please update expectations in Source/[WebKit/WebCore]/SaferCPPExpectations by running the following commands and update your pull request:

  • Tools/Scripts/update-safer-cpp-expectations -p WebCore --NoUncheckedPtrMemberChecker workers/service/context/ServiceWorkerDebuggable.h
  • Tools/Scripts/update-safer-cpp-expectations -p WebCore --UncountedCallArgsChecker bindings/js/JSExecState.h

…ng a module containing a top-level await

https://bugs.webkit.org/show_bug.cgi?id=242740
<rdar://problem/97370038>

Reviewed by NOBODY (OOPS!).

This change completely re-implements module loader to precisely follow the spec steps [1],
resolving multiple issues revolving around importing modules with top-level `await`.

Infinite retry of module fetching & parsing is removed as it's not part of the spec,
nor other browsers behave in the same way.

This patch also rewires the way module loader is hooked into workers / worklets, which became
necessary due to functions like evaluateModule() became always `async`. Along with this,
errors occuring in modules with top-level `await` are now properly reported to the console,
resolving another developers' pain point.

[1]: https://tc39.es/ecma262/#sec-cyclic-module-records

* JSTests/test262/expectations.yaml:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/cors-crossorigin-requests-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/repeated-imports.any-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/repeated-imports.any.sharedworker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/repeated-imports.any.worker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/checkpoint-after-workerglobalscope-onerror-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/checkpoint-after-workerglobalscope-onerror-module-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/evaluation-order-1-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/evaluation-order-1-throw-importScripts.any.sharedworker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/evaluation-order-1-throw-importScripts.any.worker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/evaluation-order-2-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/choice-of-error-2-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/choice-of-error-3-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/crossorigin-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/dynamic-import/blob-url.any-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/dynamic-import/blob-url.any.sharedworker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/dynamic-import/blob-url.any.worker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/dynamic-import/dynamic-imports-fetch-error.sub-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/dynamic-import/dynamic-imports-script-error-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/error-type-2-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/error-type-3-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-error-1-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-error-2-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-error-3-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-error-4-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/instantiation-error-1-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/instantiation-error-2-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/instantiation-error-3-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/instantiation-error-4-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/instantiation-error-5-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/instantiation-error-6-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/instantiation-error-7-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/webappapis/scripting/events/event-handler-processing-algorithm-error/worker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/workers/modules/dedicated-worker-import-blob-url.any-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/workers/modules/dedicated-worker-import-blob-url.any.worker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/workers/modules/dedicated-worker-import-failure-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/workers/modules/dedicated-worker-parse-error-failure-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/workers/modules/shared-worker-import-blob-url.window-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/workers/modules/shared-worker-parse-error-failure-expected.txt:
* Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj:
* Source/JavaScriptCore/builtins/BuiltinNames.h:
* Source/JavaScriptCore/builtins/ModuleLoader.js:
(visibility.PrivateRecursive.ensureModuleMapEntry):
(visibility.PrivateRecursive.hostFetchAndLoadImportedModule):
(visibility.PrivateRecursive.hostLoadImportedModule):
(visibility.PrivateRecursive.fetchDescendantsOfAndLink):
(visibility.PrivateRecursive.innerModuleLoading):
(visibility.PrivateRecursive.moduleLinking):
(visibility.PrivateRecursive.innerModuleLinking):
(visibility.PrivateRecursive.moduleEvaluation):
(visibility.PrivateRecursive.innerModuleEvaluation):
(visibility.PrivateRecursive.async executeAsyncModule):
(linkTimeConstant.gatherAvailableAncestors):
(visibility.PrivateRecursive.asyncModuleExecutionFulfilled):
(linkTimeConstant.asyncModuleExecutionRejected):
(visibility.PrivateRecursive.fetchModule):
(visibility.PrivateRecursive.fetchModuleAndEvaluate):
(visibility.PrivateRecursive.evaluateModule):
(visibility.PrivateRecursive.loadModule):
(visibility.PrivateRecursive.loadModuleAndEvaluate):
(visibility.PrivateRecursive.requestImportModule):
(visibility.PrivateRecursive.dependencyKeysIfEvaluated):
(linkTimeConstant.setStateToMax): Deleted.
(linkTimeConstant.newRegistryEntry): Deleted.
(visibility.PrivateRecursive.ensureRegistered): Deleted.
(linkTimeConstant.forceFulfillPromise): Deleted.
(linkTimeConstant.fulfillFetch): Deleted.
(visibility.PrivateRecursive.requestFetch): Deleted.
(linkTimeConstant.cacheSatisfy): Deleted.
(async linkTimeConstant.cacheSatisfyAndReturn): Deleted.
(visibility.PrivateRecursive.requestSatisfy): Deleted.
(visibility.PrivateRecursive.requestSatisfyUtil): Deleted.
(visibility.PrivateRecursive.link): Deleted.
(visibility.PrivateRecursive.async asyncModuleEvaluation): Deleted.
(visibility.PrivateRecursive.provideFetch): Deleted.
(visibility.PrivateRecursive.async loadModule): Deleted.
(visibility.PrivateRecursive.linkAndEvaluateModule): Deleted.
(visibility.PrivateRecursive.async loadAndEvaluateModule): Deleted.
(visibility.PrivateRecursive.async requestImportModule): Deleted.
* Source/JavaScriptCore/bytecode/BytecodeIntrinsicRegistry.cpp:
(JSC::BytecodeIntrinsicRegistry::BytecodeIntrinsicRegistry):
* Source/JavaScriptCore/bytecode/BytecodeIntrinsicRegistry.h:
* Source/JavaScriptCore/jsc.cpp:
(dumpException):
(runWithOptions):
* Source/JavaScriptCore/parser/Parser.cpp:
(JSC::Parser<LexerType>::parseInner):
* Source/JavaScriptCore/runtime/AbstractModuleRecord.cpp:
(JSC::AbstractModuleRecord::hostResolveImportedModule):
(JSC::AbstractModuleRecord::link):
* Source/JavaScriptCore/runtime/ArrayPrototype.cpp:
(JSC::ArrayPrototype::finishCreation):
* Source/JavaScriptCore/runtime/Completion.cpp:
(JSC::createSymbolForEntryPointModule): Deleted.
(JSC::rejectPromise): Deleted.
(JSC::loadAndEvaluateModule): Deleted.
(JSC::loadModule): Deleted.
(JSC::linkAndEvaluateModule): Deleted.
* Source/JavaScriptCore/runtime/Completion.h:
* Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
* Source/JavaScriptCore/runtime/JSModuleLoader.cpp:
(JSC::JSModuleLoader::finishCreation):
(JSC::createSymbolForEntryPointModule):
(JSC::JSModuleLoader::loadModule):
(JSC::JSModuleLoader::loadModuleAndEvaluate):
(JSC::JSModuleLoader::fetchModule):
(JSC::JSModuleLoader::fetchModuleAndEvaluate):
(JSC::JSModuleLoader::evaluateModule):
(JSC::JSC_DEFINE_HOST_FUNCTION):
(JSC::JSModuleLoader::provideFetch): Deleted.
(JSC::JSModuleLoader::loadAndEvaluateModule): Deleted.
(JSC::JSModuleLoader::linkAndEvaluateModule): Deleted.
* Source/JavaScriptCore/runtime/JSModuleLoader.h:
* Source/JavaScriptCore/runtime/SyntheticModuleRecord.cpp:
(JSC::SyntheticModuleRecord::link):
* Source/JavaScriptCore/runtime/SyntheticModuleRecord.h:
* Source/JavaScriptCore/wasm/js/WebAssemblyModuleRecord.cpp:
(JSC::WebAssemblyModuleRecord::link):
* Source/JavaScriptCore/wasm/js/WebAssemblyModuleRecord.h:
* Source/WebCore/bindings/js/JSExecState.h:
(WebCore::JSExecState::loadModule):
(WebCore::JSExecState::loadModuleAndEvaluate):
(WebCore::JSExecState::fetchModule):
(WebCore::JSExecState::fetchModuleAndEvaluate):
(WebCore::JSExecState::evaluateModule):
(WebCore::JSExecState::linkAndEvaluateModule): Deleted.
* Source/WebCore/bindings/js/ScheduledAction.cpp:
(WebCore::ScheduledAction::execute):
* Source/WebCore/bindings/js/ScriptController.cpp:
(WebCore::ScriptController::loadModuleScriptInWorld):
(WebCore::ScriptController::evaluateModuleScriptInWorld):
(WebCore::ScriptController::evaluateModuleScript):
(WebCore::ScriptController::linkAndEvaluateModuleScriptInWorld): Deleted.
(WebCore::ScriptController::linkAndEvaluateModuleScript): Deleted.
* Source/WebCore/bindings/js/ScriptController.h:
* Source/WebCore/bindings/js/WorkerScriptFetcher.h:
* Source/WebCore/dom/ScriptElement.cpp:
(WebCore::ScriptElement::executeModuleScript):
* Source/WebCore/workers/DedicatedWorkerThread.h:
(WebCore::DedicatedWorkerThread::workerObjectProxy const):
(WebCore::DedicatedWorkerThread::start): Deleted.
* Source/WebCore/workers/WorkerOrWorkletScriptController.cpp:
(WebCore::WorkerOrWorkletScriptController::evaluateAndReportException):
(WebCore::WorkerOrWorkletScriptController::evaluate):
(WebCore::WorkerOrWorkletScriptController::loadModuleAndEvaluate):
(WebCore::WorkerOrWorkletScriptController::fetchWorkletModuleAndEvaluate):
(WebCore::jsValueToModuleKey): Deleted.
(WebCore::WorkerOrWorkletScriptController::loadModuleSynchronously): Deleted.
(WebCore::WorkerOrWorkletScriptController::linkAndEvaluateModule): Deleted.
(WebCore::WorkerOrWorkletScriptController::loadAndEvaluateModule): Deleted.
* Source/WebCore/workers/WorkerOrWorkletScriptController.h:
* Source/WebCore/workers/WorkerOrWorkletThread.cpp:
(WebCore::WorkerOrWorkletThread::workerOrWorkletThread):
* Source/WebCore/workers/WorkerOrWorkletThread.h:
(WebCore::WorkerOrWorkletThread::evaluateScriptIfNecessary):
* Source/WebCore/workers/WorkerThread.cpp:
(WebCore::WorkerThread::evaluateScriptIfNecessary):
* Source/WebCore/workers/WorkerThread.h:
* Source/WebCore/workers/shared/context/SharedWorkerContextManager.cpp:
(WebCore::SharedWorkerContextManager::registerSharedWorkerThread):
* Source/WebCore/worklets/WorkletGlobalScope.cpp:
(WebCore::WorkletGlobalScope::evaluate):
(WebCore::WorkletGlobalScope::fetchAndInvokeScript):
@shvaikalesh shvaikalesh removed the merging-blocked Applied to prevent a change from being merged label Oct 10, 2024
@shvaikalesh shvaikalesh force-pushed the eng/JSC-ReferenceError-when-multiple-modules-are-simultaneously-importing-a-module-containing-a-top-level-await branch from 7708e7d to cf39202 Compare October 10, 2024 02:35
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Oct 10, 2024
@webkit-ews-buildbot
Copy link
Collaborator

Safer C++ Build #988

❌ Found 1 new failure. Please address these issues before landing. See WebKit Guidelines for Safer C++ Programming.
(cc @rniwa)

⚠️ Found 1 fixed file! Please update expectations in Source/[WebKit/WebCore]/SaferCPPExpectations by running the following commands and update your pull request:

  • Tools/Scripts/update-safer-cpp-expectations -p WebCore --NoUncheckedPtrMemberChecker workers/service/context/ServiceWorkerDebuggable.h
  • Tools/Scripts/update-safer-cpp-expectations -p WebCore --UncountedCallArgsChecker bindings/js/JSExecState.h

@kalegd
Copy link

kalegd commented Oct 31, 2024

Just expressing additional interest in seeing these changes go through as it's not uncommon to run into this issue. Thanks for the hard work

@ilyakamens
Copy link

Just expressing additional interest in seeing these changes go through as it's not uncommon to run into this issue. Thanks for the hard work

Ditto!

@qiyundai
Copy link

qiyundai commented Dec 2, 2024

Just expressing additional interest in seeing these changes go through as it's not uncommon to run into this issue. Thanks for the hard work

Ditto!

Ditto

@MenloDorian
Copy link

This PR requires significant feature-level work to complete. We don't currently have anyone working on it, but we hear the requests and will consider it in our planning. Thanks.

@darinadler
Copy link
Member

I’m so glad someone took a crack at this, but it seems like we need quite a bit more work to complete it.

@wmertens
Copy link

wmertens commented Aug 2, 2025

is there any workaround possible, for example retrying a failed import? Any application that wants to have client code blocked until environment-specific code ran will encounter this, right?

@aralroca
Copy link

I hope this will be merged soon

@nt1m
Copy link
Member

nt1m commented Feb 14, 2026

There's an on-going rewrite that will fix this issue: #57827

@nt1m nt1m closed this Feb 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

JavaScriptCore For bugs in JavaScriptCore, the JS engine used by WebKit, other than kxmlcore issues. merging-blocked Applied to prevent a change from being merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.