mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-28 07:30:04 +00:00
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:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user