mirror of
https://github.com/nomadkaraoke/karaoke-gen.git
synced 2026-11-28 01:49:00 +09:00
@coderabbitai ignore Follow-up to #725 / #726 — found during post-deploy verification. Test-throwing from \`/admin/crash-test\` showed the default Next.js "Application error" screen instead of the CrashReport card, and no pattern landed in Firestore. Root cause: the error-handling infrastructure was scoped to \`app/[locale]/\`, so routes outside that tree (\`/admin/*\`) had no coverage. ## Fix - Move \`ClientErrorInit\` mount from \`app/[locale]/layout.tsx\` to \`app/layout.tsx\` (root). \`DefaultIntlProvider\` at root already provides \`crashReport\` translations for admin pages. - Drop the \`locale\` prop from \`ClientErrorInit\`; \`client-error-setup\` now auto-detects locale from \`window.location.pathname\` (first segment, whitelisted against known locales, falls back to \`"en"\`). - Add \`app/error.tsx\` and \`app/global-error.tsx\` at root — any uncaught React error anywhere in the app now renders the CrashReport card. - Remove the redundant \`app/[locale]/error.tsx\` and \`global-error.tsx\` (root covers them; Next.js picks the closest boundary, so removing avoids duplication). ## Tests 20/20 frontend unit tests pass. Build emits \`out/admin/crash-test/\` correctly. ## Test plan - [ ] Deploy, visit \`https://gen.nomadkaraoke.com/admin/crash-test/\` as admin. - [ ] Click "Render-time throw" → expect the CrashReport card (not the default Next.js screen). - [ ] Click "Async throw" + "Unhandled rejection" → expect two new \`service=frontend\` patterns in Firestore. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
20 lines
472 B
TypeScript
20 lines
472 B
TypeScript
'use client'
|
|
|
|
import { useEffect } from 'react'
|
|
import CrashReport from '@/components/CrashReport'
|
|
|
|
interface Props {
|
|
error: Error & { digest?: string }
|
|
reset: () => void
|
|
}
|
|
|
|
export default function RootError({ error, reset }: Props) {
|
|
useEffect(() => {
|
|
if (typeof console !== 'undefined') {
|
|
console.error('[root error.tsx]', error)
|
|
}
|
|
}, [error])
|
|
|
|
return <CrashReport error={error} source="error.tsx:root" digest={error.digest} onReset={reset} />
|
|
}
|