Reload once when a frontend chunk disappears after deploy.
Deploy Development / deploy (push) Successful in 53s
Test Suite / pytest-backend (push) Successful in 49s
Test Suite / lint-backend (push) Successful in 1s
Test Suite / build-frontend (push) Successful in 18s
Test Suite / k6 /health Baseline (push) Successful in 35s
Test Suite / playwright-tests (push) Failing after 7m43s

A stale tab otherwise requests the previous hashed Dashboard bundle and shows the route error page.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
LarsandCursor committed 2026-11-23 09:44:47 +01:00
1 parent f49de9c971
commit 0431c9e160
6 files changed
+79 -54

No files matched your search

+19 -11
View File
@@ -3,18 +3,26 @@ import { lazy } from 'react'
/**
* Lazy-Import mit Reload bei fehlendem Chunk (nach Deploy alte Hashes im Browser-Cache).
*/
const RELOAD_KEY = 'sj_chunk_reload'
export function lazyWithRetry(importFn) {
return lazy(() =>
importFn().catch((err) => {
const key = 'sj_chunk_reload'
const reloaded = sessionStorage.getItem(key)
if (!reloaded) {
sessionStorage.setItem(key, '1')
window.location.reload()
return new Promise(() => {})
}
sessionStorage.removeItem(key)
throw err
}),
importFn()
.then((mod) => {
sessionStorage.removeItem(RELOAD_KEY)
return mod
})
.catch((err) => {
const reloaded = sessionStorage.getItem(RELOAD_KEY)
if (!reloaded) {
sessionStorage.setItem(RELOAD_KEY, '1')
const url = new URL(window.location.href)
url.searchParams.set('sj_reload', String(Date.now()))
window.location.replace(url.toString())
return new Promise(() => {})
}
sessionStorage.removeItem(RELOAD_KEY)
throw err
}),
)
}