-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Description
What type of issue is this?
Browser bug (a bug with a feature that may impact site compatibility)
What information was incorrect, unhelpful, or incomplete?
Safari has a bug since at least 2022 with their support for top-level await.
More specifically, if a module containing top-level await is imported by two modules at the same time, one of the imports will fail (will be undefined or even lead to promise rejection - depends on the reproduction).
This bug makes top-level await unusable for non-trivial usages (as complex apps commonly import a given module from multiple places at the same time).
SvelteKit has to maintain an expensive workaround for this bug: sveltejs/kit#11601
I also encountered it, requiring a last minute expensive change to our release.
I would like MDN to add a note about this bug in the compatibility table to communicate to other developers that this bug exists, and to bring more attention to the need for a fix.
What browsers does this problem apply to, if applicable?
Safari
What did you expect to see?
Modules should get imported without errors and exported variables should not be undefined.
Did you test this? If so, how?
Reproduced in several tiny test apps - 3 different reproductions are mentioned in the Safari bug comments: https://bugs.webkit.org/show_bug.cgi?id=242740
I can re-post them here if necessary.
Can you link to any release notes, bugs, pull requests, or MDN pages related to this?
https://bugs.webkit.org/show_bug.cgi?id=242740
Do you have anything more you want to share?
No response
MDN URL
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/await
MDN metadata
MDN page report details
- Query:
javascript.operators.await - Report started: 2025-02-27T20:21:31.747Z