Fix #439: handle chunk load failures by reloading the page
When a new version is deployed and old chunks are replaced, users with the old HTML in-session will encounter "Loading chunk N failed" errors on lazy-loaded routes. Add a router.onError handler to detect these failures and reload the page so the browser fetches fresh HTML and updated chunk manifests. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
6858a9ad67
commit
8e7c232c0c
|
|
@ -72,3 +72,11 @@ router.afterEach(() => {
|
||||||
// finish progress bar
|
// finish progress bar
|
||||||
NProgress.done()
|
NProgress.done()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
router.onError((error) => {
|
||||||
|
const pattern = /Loading chunk (\d)+ failed/g
|
||||||
|
const isChunkLoadFailed = error.message.match(pattern)
|
||||||
|
if (isChunkLoadFailed) {
|
||||||
|
window.location.reload()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue