From 8e7c232c0cb0fee4da6ee1f52aca26aba5ce05ba Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 20 Feb 2026 21:42:59 -0800 Subject: [PATCH] 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 --- src/permission.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/permission.js b/src/permission.js index ff5eaad2..941d990f 100644 --- a/src/permission.js +++ b/src/permission.js @@ -72,3 +72,11 @@ router.afterEach(() => { // finish progress bar NProgress.done() }) + +router.onError((error) => { + const pattern = /Loading chunk (\d)+ failed/g + const isChunkLoadFailed = error.message.match(pattern) + if (isChunkLoadFailed) { + window.location.reload() + } +})