fix(prod): auto-reload on ChunkLoadError or Server Action mismatch
All checks were successful
Build & Deploy / 🔍 Prepare (push) Successful in 12s
Build & Deploy / 🏗️ Build (push) Successful in 10m30s
Build & Deploy / 🚀 Deploy (push) Successful in 27s
Build & Deploy / 🩺 Smoke Test (push) Successful in 7s
Build & Deploy / 🔔 Notify (push) Successful in 4s

This commit is contained in:
2026-06-10 11:11:54 +02:00
parent 3fac158185
commit ede34ab7ce
2 changed files with 32 additions and 1 deletions

View File

@@ -15,6 +15,22 @@ export default function Error({
// Log the error to Sentry/GlitchTip
Sentry.captureException(error);
console.error("Caught in error.tsx:", error);
// Auto-reload on ChunkLoadError or Server Action errors to fetch the new deployment assets
const isChunkLoadError =
error.message &&
(error.message.includes("ChunkLoadError") ||
error.message.includes("Loading chunk") ||
error.message.includes("Failed to find Server Action"));
if (isChunkLoadError) {
const lastReload = sessionStorage.getItem("last-chunk-reload");
const now = Date.now();
if (!lastReload || now - parseInt(lastReload) > 10000) {
sessionStorage.setItem("last-chunk-reload", now.toString());
window.location.reload();
}
}
}, [error]);
return (

View File

@@ -1,7 +1,6 @@
"use client";
import * as Sentry from "@sentry/nextjs";
import Error from "next/error";
import { useEffect } from "react";
import { Inter, Newsreader } from "next/font/google";
import "./globals.css";
@@ -23,6 +22,22 @@ export default function GlobalError({
}) {
useEffect(() => {
Sentry.captureException(error);
// Auto-reload on ChunkLoadError or Server Action errors to fetch the new deployment assets
const isChunkLoadError =
error.message &&
(error.message.includes("ChunkLoadError") ||
error.message.includes("Loading chunk") ||
error.message.includes("Failed to find Server Action"));
if (isChunkLoadError) {
const lastReload = sessionStorage.getItem("last-chunk-reload");
const now = Date.now();
if (!lastReload || now - parseInt(lastReload) > 10000) {
sessionStorage.setItem("last-chunk-reload", now.toString());
window.location.reload();
}
}
}, [error]);
return (