fix(client): five loads that catch their own error recover from a deploy too

The PDF export on desktop and phone, the language switch, the holiday
regions and the PDF's map image load a chunk on demand and catch the
failure themselves. After a deploy the old page asks for chunk names the
new build no longer has, so they showed their own error on every retry
(or, for the language, silently stayed in the old one) instead of
reloading onto the new build the way an uncaught chunk error does.
importChunk reloads once for a missing chunk and still hands the caller
its error.
This commit is contained in:
Maurice
2026-10-07 17:05:36 +02:00
parent 0a1a5092f7
commit c3c21fb0b4
7 changed files with 39 additions and 6 deletions
+16
View File
@@ -116,3 +116,19 @@ export function clearChunkReloadMarker(): void {
// Nothing to clear if storage is unavailable.
}
}
/**
* A dynamic import whose failure the caller catches. After a deploy the old
* page asks for chunk names the new build no longer has; a caller that only
* shows its own error would show it on every retry, so a missing chunk reloads
* onto the current build once, the way an uncaught one already does. The
* error is rethrown for the caller either way.
*/
export async function importChunk<T>(load: () => Promise<T>): Promise<T> {
try {
return await load()
} catch (err) {
if (isChunkLoadError(err)) reloadOnceForChunk()
throw err
}
}