Skip to content

Commit

Permalink
Merge pull request #1476 from argos-ci/fix-dynamic-import-failure-cat…
Browse files Browse the repository at this point in the history
…ching

feat: support Safari for dynamic import loading failure
  • Loading branch information
gregberge authored Dec 17, 2024
2 parents 2275e1c + f5857a3 commit 1516b81
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 1516b81

Please sign in to comment.