WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
NEW
242740
[JSC] ReferenceError when multiple modules are simultaneously importing a module containing a top-level await
https://bugs.webkit.org/show_bug.cgi?id=242740
Summary
[JSC] ReferenceError when multiple modules are simultaneously importing a mod...
ardtimmerman+webkit
Reported
2022-07-14 02:49:31 PDT
Created
attachment 460889
[details]
Test case reduction -- also includes a README explaining the steps to reproduce the issue When modules are simultaneously fetching an import which requires some setup time due to top-level await, one of the imports will be rejected. This doesn't happen when the modules are fetched sequentially. Note, I'm not aware of what the spec has to say about how this should be implemented, but I did note that this behavior is not consistent with other browsers. When running the attached test case reduction on either chrome or firefox, none of the promises will be rejected. (reproduced this using WebKit 16612(.3.6.1.8))
Attachments
Test case reduction -- also includes a README explaining the steps to reproduce the issue
(12.92 KB, application/zip)
2022-07-14 02:49 PDT
,
ardtimmerman+webkit
no flags
Details
View All
Add attachment
proposed patch, testcase, etc.
Radar WebKit Bug Importer
Comment 1
2022-07-21 02:50:20 PDT
<
rdar://problem/97370038
>
Jimmy Wärting
Comment 2
2023-02-18 03:38:14 PST
able to reproduce, i stubble upon this issue today myself... FF/Blink works OK it's hard to really do any workaround without doing a major refactor. It's not like you can polyfill this in anyway. so i wish this could be fixed/prioritized. ...non essential issues that can be solved with polyfills can get a lower priority I would consider this to be more of a bug than a feature request.
agafvv
Comment 3
2023-08-24 02:36:23 PDT
I've encountered into this problem myself and spent a lot of time debugging due to unformatted error messages.
https://github.com/sveltejs/kit/issues/7805
- message in the SvelteKit repository, where other developers have encountered this bug. Please prioritize fixing it!
Jack Koppa
Comment 4
2023-11-10 10:37:18 PST
Noting that we've encountered a similar issue, in our case using Web Components from Stencil -
https://github.com/ionic-team/stencil
. Issue only occurs on Safari (as per the test case reduction), and is resolved if we refactor to remove our top-level await.
pjmv
Comment 5
2024-01-12 04:57:49 PST
I've encountered "Unhandled Promise Rejection: ReferenceError: Cannot access uninitialized variable" while developing with Astro and can confirm that WebKit-based browsers handle things differently than other browsers.
Alexey Shvayka
Comment 6
2024-02-08 19:26:54 PST
Pull request:
https://github.com/WebKit/WebKit/pull/24122
linnea2
Comment 7
2024-05-15 23:49:36 PDT
(In reply to Jack Koppa from
comment #4
)
> Noting that we've encountered a similar issue, in our case using Web > Components from Stencil -
https://github.com/ionic-team/stencil
https://dinosaurgame3d.com
. Issue only > occurs on Safari (as per the test case reduction), and is resolved if we > refactor to remove our top-level await.
How can the issue that occurs specifically on Safari when using Web Components from Stencil be resolved by refactoring the code to remove the top-level await?
vrugtehagel
Comment 8
2024-06-02 00:50:53 PDT
This bit me today - it actually happens in a much simpler use-case than the one presented in this issue as well. I have a reusable async function that imports a module, and therefore is subject to importing that module multiple times. When it is called twice (or more) before the module has loaded, some of the imports resolve immediately. In a nutshell: ```js // index.js import('./mod.js').then(() => console.log('one')); import('./mod.js').then(() => console.log('two')); // mod.js await new Promise(resolve => setTimeout(resolve, 1000)); ``` Here, I expect to see the "one" and "two" logged after a second (not necessarily in that order), but instead, Safari instantly logs "two" and then logs "one" after a second. Adding more `import()` statements to this causes all but the first import to resolve immediately.
Mark Lam
Comment 9
2024-07-19 21:42:43 PDT
***
Bug 270687
has been marked as a duplicate of this bug. ***
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug