Supabase · sdk · fg-0202
Supabase queries hang forever after awaiting a Supabase call inside onAuthStateChange
The next supabase.from(...) or getSession() anywhere in the app never resolves, with no error
Verified 2026-10-15 · Confirmed by 0 builders · Trust 50/100
Cause
Older auth clients held a session lock while running onAuthStateChange callbacks, so awaiting another Supabase call inside the callback waited on the same lock. Version 2.107.0 removed the navigator.locks mutex.
Fix
Upgrade to supabase-js 2.107.0 or later. On older versions keep the callback synchronous and defer any Supabase call with setTimeout. Even on new versions, never call refreshSession from a TOKEN_REFRESHED handler.
Apply
supabase.auth.onAuthStateChange((event, session) => {
setSession(session); // sync only
setTimeout(async () => {
await supabase.from('profiles').select('*').eq('id', session?.user.id);
}, 0);
});
npm install @supabase/supabase-js@^2.107.0Affects: @supabase/supabase-js 2.x before 2.107.0 (released 2026-06-02); gotrue-js 2.62.0 and later in that range
Sources
- https://github.com/supabase/auth-js/issues/762
- https://github.com/supabase/supabase-js/issues/936
- https://github.com/supabase/supabase-js/releases/tag/v2.107.0
Have your agent know this before it fails
claude mcp add --transport http footgun https://getfootgun.com/api/mcp