Skip to content

Commit

Permalink
feat: support Safari for dynamic import loading failure
Browse files Browse the repository at this point in the history
ARGOS-BROWSER-9N
  • Loading branch information
gregberge committed Dec 17, 2024
1 parent efeb188 commit f5857a3
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions apps/frontend/src/router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit f5857a3

Please sign in to comment.