mirror of
https://github.com/supabase/supabase.git
synced 2026-12-05 07:59:03 +00:00
## Problem The `/logout` route awaited `signOut()` without handling errors, and the returned promise was not handled either. If any step of sign-out threw (for example clearing local storage or the assistant's IndexedDB storage), the rejection went unhandled, the redirect to `/sign-in` never ran, and the page stayed on the loading spinner indefinitely. ## Solution Wrap the sign-out in `try / catch / finally` in `apps/studio/routes/logout.tsx`: - On success, show the existing "Successfully logged out" toast. - On failure, log the error and show an error toast. - In both cases, navigate to `/sign-in`. The promise from the async `logout()` call is now explicitly discarded with `void`, since it can no longer reject. ## Review instructions 1. Sign in to the preview, then open `/dashboard/logout`. You see "Successfully logged out" and land on `/dashboard/sign-in`. 2. To check the failure path, make sign-out throw (for example, block IndexedDB for the site, or temporarily throw in `useSignOut`), then open `/dashboard/logout`. You see an error toast and still land on `/dashboard/sign-in` instead of a spinner that never ends. Checks run: `pnpm turbo run typecheck --filter='...[origin/master]'`, `pnpm turbo run lint --filter='[origin/master]'`, and Prettier on the changed file. There are no unit tests for this route. The Studio lint type-check ran out of memory on the first run with the default Node heap and passed with a larger heap. ## Checklist - [x] I have read [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) [FE-5123](https://linear.app/supabase/issue/FE-5123/logout-page-gets-stuck-if-sign-out-fails) Co-authored-by: supabase-vercel-tedd[bot] <336548405+supabase-vercel-tedd[bot]@users.noreply.github.com>
37 lines
890 B
TypeScript
37 lines
890 B
TypeScript
import { createFileRoute, useNavigate } from '@tanstack/react-router'
|
|
import { useEffect } from 'react'
|
|
import { toast } from 'sonner'
|
|
import { LogoLoader } from 'ui'
|
|
|
|
import { useSignOut } from '@/lib/auth'
|
|
|
|
export const Route = createFileRoute('/logout')({
|
|
component: LogoutPage,
|
|
})
|
|
|
|
function LogoutPage() {
|
|
const navigate = useNavigate()
|
|
const signOut = useSignOut()
|
|
|
|
useEffect(() => {
|
|
const logout = async () => {
|
|
try {
|
|
await signOut()
|
|
toast('Successfully logged out')
|
|
} catch (error) {
|
|
console.error('Failed to sign out', error)
|
|
toast.error('Something went wrong while signing out. Please sign in again.')
|
|
} finally {
|
|
await navigate({ to: '/sign-in' })
|
|
}
|
|
}
|
|
void logout()
|
|
}, [])
|
|
|
|
return (
|
|
<div className="w-full h-screen flex items-center justify-center">
|
|
<LogoLoader />
|
|
</div>
|
|
)
|
|
}
|