import { isError } from 'lodash' import { ExternalLink } from 'lucide-react' import Link from 'next/link' import { useRouter } from 'next/router' import CopyButton from './CopyButton' import Image from 'next/image' import { AlertDescription_Shadcn_, AlertTitle_Shadcn_, Alert_Shadcn_, Button, WarningIcon, cn, } from 'ui' import { InlineLinkClassName } from './InlineLink' // More correct version of FallbackProps from react-error-boundary export type FallbackProps = { error: unknown resetErrorBoundary: (...args: any[]) => void } export const GlobalErrorBoundaryState = ({ error, resetErrorBoundary }: FallbackProps) => { const router = useRouter() const checkIsError = isError(error) const errorMessage = checkIsError ? error.message : '' const urlMessage = checkIsError ? `Path name: ${router.pathname}\n\n${error?.stack}` : '' const isRemoveChildError = checkIsError ? errorMessage.includes("Failed to execute 'removeChild' on 'Node'") : false const handleClearStorage = () => { try { localStorage.clear() sessionStorage.clear() } catch (e) { // ignore } window.location.reload() } return (
Supabase

Sorry! An unexpected error occurred.

Application error: a client-side exception has occurred (see browser console for more information)

{errorMessage}

{isRemoveChildError ? ( This error might be caused by Google translate or third-party browser extensions You may try to avoid using Google translate or disable certain browser extensions to avoid running into the 'removeChild' on 'Node' error. ) : ( We recommend trying the following:
  • window.location.reload()} > Refresh {' '} the page
  • router.push('/logout')} > Sign out {' '} and sign back in
  • Clear your browser storage {' '} to clean potentially outdated data
  • Disable browser extensions that might modify page content (e.g., Google Translate)
  • If the problem persists, please contact support for assistance
)}
{/* [Joshen] For local and staging, allow us to escape the error boundary */} {/* We could actually investigate how to make this available on prod, but without being able to reliably test this, I'm not keen to do it now */} {process.env.NEXT_PUBLIC_ENVIRONMENT !== 'prod' ? ( ) : ( )}
) }