mirror of
https://github.com/supabase/supabase.git
synced 2026-12-06 00:19:08 +00:00
## I have read the [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) file. YES ## What kind of change does this PR introduce? Bug fix ## What is the current behavior? Please link any relevant issues here: Resolves **#46593** There is a navigation race condition in `apps/studio/components/interfaces/SignIn/SignInPartner.tsx`. On mount, an IIFE fetches `auth.getSession()` and potentially `auth.signInWithIdToken()`. If the user navigates away from the page (unmounting the component) while these network promises are still pending, the `finally` or `else` blocks will still execute `router.replace()`. This forces an unintended "ghost redirect" that hijacks the user's active session and pulls them away from their current page. ## What is the new behavior? This PR introduces a standard `isMounted` flag to guard the asynchronous operations inside the `useEffect` hook. * A cleanup function now correctly flips the `isMounted` flag to `false` when the component unmounts. * An early exit `if (!isMounted) return` prevents unnecessary execution if the component is destroyed during the initial session fetch. * The `router.replace()` calls are now wrapped in `if (isMounted)` checks, ensuring that redirects only trigger if the component is still active in the DOM. ## Additional context This is an isolated frontend lifecycle patch. Local pre-flight checks (`pnpm typecheck`, `pnpm lint --filter=studio`, and `pnpm test:studio`) have all passed successfully. --------- Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com>