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
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:
@@ -15,6 +15,22 @@ export default function Error({
|
|||||||
// Log the error to Sentry/GlitchTip
|
// Log the error to Sentry/GlitchTip
|
||||||
Sentry.captureException(error);
|
Sentry.captureException(error);
|
||||||
console.error("Caught in error.tsx:", 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]);
|
}, [error]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import * as Sentry from "@sentry/nextjs";
|
import * as Sentry from "@sentry/nextjs";
|
||||||
import Error from "next/error";
|
|
||||||
import { useEffect } from "react";
|
import { useEffect } from "react";
|
||||||
import { Inter, Newsreader } from "next/font/google";
|
import { Inter, Newsreader } from "next/font/google";
|
||||||
import "./globals.css";
|
import "./globals.css";
|
||||||
@@ -23,6 +22,22 @@ export default function GlobalError({
|
|||||||
}) {
|
}) {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
Sentry.captureException(error);
|
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]);
|
}, [error]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user