Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(frontend): treat WebKit "Importing a module script failed" as chunk-load error (#61821)

eleftheriatrivyzaki169d3be3ecd4
diff --git a/frontend/src/lib/utils/isChunkLoadError.test.ts b/frontend/src/lib/utils/isChunkLoadError.test.ts
index cbb1370a2ad7..0263cf25155d 100644
--- a/frontend/src/lib/utils/isChunkLoadError.test.ts
+++ b/frontend/src/lib/utils/isChunkLoadError.test.ts
@@ -19,6 +19,16 @@ describe('isChunkLoadError', () => {
{ name: 'TypeError', message: 'error loading dynamically imported module: /static/chunk.js' },
true,
],
+ [
+ 'WebKit module-script load failure (TypeError)',
+ { name: 'TypeError', message: 'Importing a module script failed.' },
+ true,
+ ],
+ [
+ 'WebKit module-script load failure (plain Error, not TypeError)',
+ { name: 'Error', message: 'Importing a module script failed.' },
+ true,
+ ],
['generic TypeError', { name: 'TypeError', message: 'undefined is not a function' }, false],
['unrelated Error', { name: 'Error', message: 'something else' }, false],
['error with no name or message', {}, false],
diff --git a/frontend/src/lib/utils/isChunkLoadError.ts b/frontend/src/lib/utils/isChunkLoadError.ts
index 4da5e3a3cd92..20dfc2fcebce 100644
--- a/frontend/src/lib/utils/isChunkLoadError.ts
+++ b/frontend/src/lib/utils/isChunkLoadError.ts
@@ -5,6 +5,7 @@
* - Safari: native `TypeError: Load failed` (no JS stack — see load-failed.tsx known exception)
* - Firefox: native `TypeError: NetworkError when attempting to fetch resource.`
* - Firefox: native `TypeError: error loading dynamically imported module: <url>` (deferred import of a now-deleted chunk after a deploy)
+ * - WebKit/Safari: `Importing a module script failed.` (module script fails to load, e.g. transient network failure)
*/
export function isChunkLoadError(error: unknown): boolean {
if (!error || typeof error !== 'object') {
@@ -16,6 +17,7 @@ export function isChunkLoadError(error: unknown): boolean {
return (
err.name === 'ChunkLoadError' ||
message.includes('Failed to fetch dynamically imported module') ||
+ message.includes('Importing a module script failed') ||
(isTypeError && message.includes('Load failed')) ||
(isTypeError && message.includes('NetworkError when attempting to fetch resource')) ||
(isTypeError && message.includes('error loading dynamically imported module'))