import * as Sentry from '@sentry/react' import { type ReactNode, useEffect, useRef } from 'react' import { Button } from '@/components/ui/Button' interface FallbackProps { error: Error resetError: () => void } function isChunkLoadError(error: Error): boolean { const msg = error.message || '' return ( msg.includes('dynamically imported module') || msg.includes('Loading chunk') || msg.includes('Failed to fetch') || error.name === 'ChunkLoadError' ) } function DefaultFallback({ error, resetError }: FallbackProps) { const reloadingRef = useRef(false) // Auto-reload on stale chunk errors (happens after deployments) useEffect(() => { if (!isChunkLoadError(error)) return const key = 'rf_boundary_chunk_reload' const lastReload = sessionStorage.getItem(key) const now = Date.now() if (!lastReload || now - Number(lastReload) > 10_000) { sessionStorage.setItem(key, String(now)) reloadingRef.current = true window.location.reload() } }, [error]) return (
An unexpected error occurred. Please try refreshing the page.
{error.message}