fix(web): recover from Vite CSS preload failures
This commit is contained in:
@@ -15,6 +15,7 @@ test("R6 route meta title and chunk recovery match Sub2API navigation pattern",
|
||||
assert.equal(resolveDocumentTitle(" "), "平台控制台 - HWLAB Cloud Web");
|
||||
assert.equal(isChunkLoadError(new Error("Failed to fetch dynamically imported module")), true);
|
||||
assert.equal(isChunkLoadError(new Error("Loading CSS chunk 42 failed")), true);
|
||||
assert.equal(isChunkLoadError(new Error("Unable to preload CSS for /assets/MdtodoView.css")), true);
|
||||
assert.equal(isChunkLoadError(new Error("ordinary route guard failure")), false);
|
||||
|
||||
const memory = new Map<string, string>();
|
||||
|
||||
@@ -8,7 +8,7 @@ const CHUNK_RELOAD_WINDOW_MS = 10_000;
|
||||
|
||||
export function isChunkLoadError(error: unknown): boolean {
|
||||
const message = error instanceof Error ? error.message : String(error ?? "");
|
||||
return /Loading chunk|Loading CSS chunk|Failed to fetch dynamically imported module|Importing a module script failed|dynamically imported module/u.test(message);
|
||||
return /Loading chunk|Loading CSS chunk|Unable to preload CSS|Failed to fetch dynamically imported module|Importing a module script failed|dynamically imported module/u.test(message);
|
||||
}
|
||||
|
||||
export function shouldReloadForChunkError(now = Date.now(), storage: Pick<Storage, "getItem" | "setItem"> = window.sessionStorage): boolean {
|
||||
|
||||
Reference in New Issue
Block a user