From f5857a3d78ed320ad4533ecd2bc53f56db934b30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Greg=20Berg=C3=A9?= Date: Tue, 17 Dec 2024 09:40:41 +0100 Subject: [PATCH] feat: support Safari for dynamic import loading failure ARGOS-BROWSER-9N --- apps/frontend/src/router.tsx | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/apps/frontend/src/router.tsx b/apps/frontend/src/router.tsx index 1c400b05e..716509a99 100644 --- a/apps/frontend/src/router.tsx +++ b/apps/frontend/src/router.tsx @@ -44,11 +44,23 @@ function Root() { ); } -const failedToFetchRegex = - /(Failed to fetch)|(error loading dynamically imported module)/; +/** + * Check if the error is a failed to fetch error. + */ +const DYNAMIC_IMPORT_MODULE_FAILED_TO_LOAD = [ + // Blink + "Failed to fetch", + // Firefox + "error loading dynamically imported module", + // Safari + "Importing a module script failed.", +]; function checkIsFailedToFetchError(error: unknown) { - return error instanceof Error && failedToFetchRegex.test(error.message); + return ( + error instanceof Error && + DYNAMIC_IMPORT_MODULE_FAILED_TO_LOAD.includes(error.message) + ); } function checkHasReloaded() {