From feb9cf01ed3206e35854f7debd5da578eba7ecd0 Mon Sep 17 00:00:00 2001 From: Yangshun Tay Date: Sat, 11 Jun 2022 17:03:11 +0800 Subject: [PATCH] fix: force refresh on chunk preload error (#7600) * fix: force refresh on preload error * misc: add comment * Update PendingNavigation.tsx --- packages/docusaurus/src/client/PendingNavigation.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/docusaurus/src/client/PendingNavigation.tsx b/packages/docusaurus/src/client/PendingNavigation.tsx index e1e38f40f817..3c1eaaf0dae3 100644 --- a/packages/docusaurus/src/client/PendingNavigation.tsx +++ b/packages/docusaurus/src/client/PendingNavigation.tsx @@ -70,7 +70,13 @@ class PendingNavigation extends React.Component { this.routeUpdateCleanupCb(); this.setState({nextRouteHasLoaded: true}); }) - .catch((e: unknown) => console.warn(e)); + .catch((e: unknown) => { + console.warn(e); + // If chunk loading failed, it could be because the path to a chunk + // no longer exists due to a new deployment. Force refresh the page + // instead of just not navigating. + window.location.reload(); + }); return false; }