Skip to content
VibeSafeDaily

LibraryAuth

The app freezes after sign-in

Cataloged October 16, 2026 · Lovable · Bolt · Cursor · Supabase

Symptom

Login returns, then the next Supabase call never comes back. The screen stays on a spinner.

Root cause

Supabase's troubleshooting note says there is a bug in supabase-js: an async API call inside onAuthStateChange deadlocks the client. If the handler awaits another Supabase call, the next call anywhere on that client hangs and does not return. The note points at the gotrue-js discussion of the same bug. Generated apps often await a profile select directly inside that callback.

Fix prompt

In this project only, find every supabase.auth.onAuthStateChange callback.

The callback must not be async, and it must not await supabase.from, storage, functions, or auth methods. Keep it synchronous: store the session, then schedule other work so the callback has returned first:

supabase.auth.onAuthStateChange((event, session) => {
  setSession(session)
  if (session) {
    setTimeout(() => {
      void loadProfile(session.user.id)
    }, 0)
  }
})

Do not add more loading flags as a workaround. After the change, sign in and confirm the next query returns.

Paste this into the coding tool that has your own project open.

2-minute self-check

These steps are for an app you own. Do not run them against someone else's project.

  1. Search your own code for onAuthStateChange. If the callback is async or awaits a Supabase call, this is the bug.
  2. Sign in to your own app and watch the network tab. The request after SIGNED_IN should finish, not stay pending.
  3. Switch away and back. A token refresh should not leave the UI stuck.

Sources

Same symptom