Files
Jyotisha/frontend/src/lib/stale-client-recovery.ts
T
Jesse_Chen 50e1a4aca5 fix(web): reload stale clients instead of spinning after a release
Homepage bootstrap never escaped the loading shell when a new web image changed chunk hashes. Stamp deploymentId, stop caching chat HTML, and hard-reload failed chunk loads once.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-21 10:29:43 +08:00

26 lines
925 B
TypeScript

export const STALE_CLIENT_RELOAD_KEY = "jyotisha:stale-client-reload";
const CHUNK_FAILURE = /ChunkLoadError|Loading chunk .+ failed|Failed to fetch dynamically imported module|error loading dynamically imported module|_next\/static\//i;
export function isChunkLoadFailure(message: string): boolean {
return CHUNK_FAILURE.test(message);
}
export function consumeStaleClientReload(storage: Pick<Storage, "getItem" | "setItem">): boolean {
if (storage.getItem(STALE_CLIENT_RELOAD_KEY) === "1") return false;
storage.setItem(STALE_CLIENT_RELOAD_KEY, "1");
return true;
}
export function clearStaleClientReload(storage: Pick<Storage, "removeItem">): void {
storage.removeItem(STALE_CLIENT_RELOAD_KEY);
}
export function shouldReloadFrozenBootstrap(input: {
persisted: boolean;
loadingBusy: boolean;
loadingError: boolean;
}): boolean {
return input.persisted && input.loadingBusy && !input.loadingError;
}