Skip to content

Commit

Permalink
fix: Reload page on dynamic module load error (#2777)
Browse files Browse the repository at this point in the history
* Reload page on dynamic module load error

* Add sentry exception to make sure that we are reloading page
  • Loading branch information
agualis authored Feb 8, 2023
1 parent b70a371 commit 3750948
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/plugins/router/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router';
import { captureException } from '@sentry/browser';

import { isGoerli } from '@/composables/useNetwork';
import { applyNavGuards } from './nav-guards';
Expand Down Expand Up @@ -204,4 +205,16 @@ const router = createRouter({
},
});

router.onError((error, to) => {
if (error.message.includes('Failed to fetch dynamically imported module')) {
captureException(
'Triggered automatic reload after failed to fetch dynamically imported module. ',
{
extra: error.message,
}
);
window.location.href = to.fullPath;
}
});

export default applyNavGuards(router);

0 comments on commit 3750948

Please sign in to comment.