Merge pull request #2228 from pikasTech/fix/2226-css-preload-recovery

fix(web): recover from Vite CSS preload failures
This commit is contained in:
Lyon
2026-06-27 15:05:41 +08:00
committed by GitHub
2 changed files with 2 additions and 1 deletions
@@ -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>();
+1 -1
View File
@@ -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 {