"use client"; import { useEffect } from "react"; import { reloadOnceForChunkError } from "@/lib/pwa/chunk-reload"; /** * Root-level error boundary. Renders when even the root layout itself fails, * so it cannot rely on any providers (i18n, query, auth). Keep it static, * in English, and self-contained. */ export default function GlobalError({ error, reset, }: { error: Error & { digest?: string }; reset: () => void; }) { // A chunk of the root layout's client tree missing after a deploy lands // here rather than in `app/error.tsx`; it gets the same single reload. useEffect(() => { reloadOnceForChunkError(error); }, [error]); async function handleCopy() { // Strip query string — OAuth callback routes carry sensitive tokens. const loc = typeof window !== "undefined" ? window.location : null; const payload = { message: error.message, digest: error.digest, name: error.name, stack: error.stack?.split("\n").slice(0, 10).join("\n"), urlPath: loc?.pathname ?? null, userAgent: typeof navigator !== "undefined" ? navigator.userAgent : null, timestamp: new Date().toISOString(), }; const text = JSON.stringify(payload, null, 2); try { await navigator.clipboard.writeText(text); } catch { window.prompt("Copy details", text); } } return (
{/* v1.4.43 QoL — bilingual lockup so a German user landing in this boundary doesn't read pure English in an already- bad-state moment. The root layout has failed by the time this fires, so no i18n provider is available; the static DE/EN pairing covers the dominant audience without a runtime cost. Copy tightened per the v1.4.43 audit (L1) to drop the verbose secondary sentence. */}

Etwas ist schiefgegangen / Something went wrong

Ein kritischer Fehler ist aufgetreten. / A critical error occurred.

            {error.message || "Unknown error"}
          
); }