-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Don't await intl-polyfill imports #28779
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR attempts to fix an issue where await import("@formatjs/intl-displaynames/polyfill-force") hangs indefinitely in Chrome 143 on macOS when loaded as part of a config panel dependency. The proposed solution removes await keywords from polyfill imports to prevent the blocking behavior.
Key changes:
- Remove
awaitfromintl-localepolyfill import (line 32) - Change from
await Promise.allSettled()to non-awaitedPromise.all()(line 69) - Add
awaittopolyfillLocaleData()call inside the promise chain (line 71)
| } | ||
| if (shouldPolyfillLocale()) { | ||
| await import("@formatjs/intl-locale/polyfill-force"); | ||
| import("@formatjs/intl-locale/polyfill-force"); |
Copilot
AI
Jan 3, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fire-and-forget import has no error handling and its result is ignored. If the polyfill import fails silently, it could cause runtime errors when the Intl.Locale API is used. Additionally, there's no guarantee this polyfill will load before the application tries to use the Intl.Locale API, potentially causing race conditions.
| import("@formatjs/intl-locale/polyfill-force"); | |
| polyfills.push(import("@formatjs/intl-locale/polyfill-force")); |
| Promise.all(polyfills).then(async () => { | ||
| // Load the default language | ||
| polyfillLocaleData(locale) | ||
| ); | ||
| await polyfillLocaleData(locale); | ||
| }); |
Copilot
AI
Jan 3, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Promise.all result is not awaited, which breaks the async flow of polyfillIntl(). The function will return immediately (line 75 has 'await polyfillIntl()'), but the polyfills won't be loaded yet. This creates a race condition where polyfillLocaleData may execute before the polyfills it depends on are loaded, causing the locale data loading to fail or be skipped since the polyfill __addLocaleData functions won't be available yet.
Proposed change
Awaiting
import("@formatjs/intl-displaynames/polyfill-force");in Chrome 143 on macOS 15.6.1 never resolves and dosen't log anything when loading it as part of a config panel dependency (submodule of https://github.com/XKNX/knx-frontend). The project just doesn't load then - an empty tag is rendered instead of the panel.This started with f2aba45
Removing
awaithere fixes this for me.Unfortunately I can't explain why this is happening or what exactly is going on here - and I would be happy if anyone would tell me 😃
For
polyfillLocaleData(locale)- afaict - it doesn't make a difference if awaited or not. Both work fine.Testing
await import("@formatjs/intl-locale/polyfill-force");- although it wouldn't load for my version of Chrome, removing the if-check it would also block indefinitely when using await.await import("@formatjs/intl-getcanonicallocales/polyfill-force");works fine.See also https://discord.com/channels/330944238910963714/1456944554786816154
Type of change
Example configuration
Additional information
Checklist
If user exposed functionality or configuration variables are added/changed: