fix: recover panel navigation after stale chunk failures (#6679)

Fixes #6673

Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
This commit is contained in:
Matt Van Horn
2026-10-02 06:01:21 -07:00
committed by GitHub
parent eef1c1eb6a
commit 921ecb0f66
2 changed files with 310 additions and 0 deletions
+26
View File
@@ -12,6 +12,32 @@ import { ThemeProvider } from '@/hooks/useTheme';
import { QueryProvider } from '@/api/QueryProvider';
import { router } from '@/routes';
// A stale tab keeps this entry's old chunk URLs after a deploy. Reload once per
// panel base path and entry URL; the same bundle must not loop on a real outage.
const chunkRecoveryKey = `xui:chunk-recovery:${window.X_UI_BASE_PATH || '/'}:${import.meta.url}`;
let chunkRecoveryCommitted = false;
window.addEventListener('vite:preloadError', (event) => {
if (chunkRecoveryCommitted) return;
chunkRecoveryCommitted = true;
let shouldReload = false;
try {
if (sessionStorage.getItem(chunkRecoveryKey) == null) {
sessionStorage.setItem(chunkRecoveryKey, '1');
shouldReload = true;
}
} catch {
chunkRecoveryCommitted = false;
return;
}
if (!shouldReload) {
chunkRecoveryCommitted = false;
return;
}
event.preventDefault();
location.reload();
});
setupHttp();
const messageContainer = document.getElementById('message');