diff --git a/app/error.tsx b/app/error.tsx index 840dae6..705d09f 100644 --- a/app/error.tsx +++ b/app/error.tsx @@ -1,5 +1,6 @@ 'use client'; +import { useEffect } from 'react'; import Link from 'next/link'; import { ArrowLeft, MessageCircle } from 'lucide-react'; @@ -20,6 +21,22 @@ const ErrorPage = ({ }) => { useCaptureException(error); + // Ignore next.js internal transient navigation errors that occur during auth state changes + const isTransientNavigationError = + error?.message?.includes('Error in input stream') || + error?.message?.includes('AbortError') || + (error?.name === 'ChunkLoadError'); + + useEffect(() => { + if (isTransientNavigationError && typeof window !== 'undefined') { + window.location.href = '/'; + } + }, [isTransientNavigationError]); + + if (isTransientNavigationError) { + return
; + } + return (
diff --git a/app/global-error.tsx b/app/global-error.tsx index 5c1d747..da6af86 100644 --- a/app/global-error.tsx +++ b/app/global-error.tsx @@ -1,5 +1,6 @@ 'use client'; +import { useEffect } from 'react'; import Link from 'next/link'; import { ArrowLeft, MessageCircle } from 'lucide-react'; @@ -20,6 +21,22 @@ const GlobalErrorPage = ({ reset: () => void; }) => { useCaptureException(error); + + // Ignore next.js internal transient navigation errors that occur during auth state changes + const isTransientNavigationError = + error?.message?.includes('Error in input stream') || + error?.message?.includes('AbortError') || + (error?.name === 'ChunkLoadError'); + + useEffect(() => { + if (isTransientNavigationError && typeof window !== 'undefined') { + window.location.href = '/'; + } + }, [isTransientNavigationError]); + + if (isTransientNavigationError) { + return
; + } return ( diff --git a/packages/supabase/src/hooks/use-auth-change-listener.ts b/packages/supabase/src/hooks/use-auth-change-listener.ts index 9409126..a022ad3 100644 --- a/packages/supabase/src/hooks/use-auth-change-listener.ts +++ b/packages/supabase/src/hooks/use-auth-change-listener.ts @@ -65,7 +65,9 @@ export function useAuthChangeListener({ return; } - window.location.reload(); + // Redirect to home instead of reloading to avoid state mismatch errors + // during the transition + window.location.assign('/'); } });