caching and redirection changes

This commit is contained in:
2025-12-30 09:20:56 -05:00
parent 77b0b3655c
commit b07ebb05b7
4 changed files with 85 additions and 44 deletions

View File

@@ -1,5 +1,30 @@
// @refresh reload
import { injectSpeedInsights } from "@vercel/speed-insights";
import { mount, StartClient } from "@solidjs/start/client";
// Handle chunk loading failures from stale cache
window.addEventListener("error", (event) => {
if (
event.message?.includes("Importing a module script failed") ||
event.message?.includes("Failed to fetch dynamically imported module")
) {
console.warn("Chunk load error detected, reloading page...");
window.location.reload();
}
});
window.addEventListener("unhandledrejection", (event) => {
if (
event.reason?.message?.includes("Importing a module script failed") ||
event.reason?.message?.includes(
"Failed to fetch dynamically imported module"
)
) {
console.warn("Chunk load error detected, reloading page...");
event.preventDefault();
window.location.reload();
}
});
injectSpeedInsights();
mount(() => <StartClient />, document.getElementById("app")!);