Skip to content

Conversation

hf
Copy link
Contributor

@hf hf commented Oct 2, 2025

If you pass in an async function to onAuthStateChange and call a Supabase Client API, it's very likely you'll end up with a deadlock. Example:

supabase.auth.onAuthStateChange(async () => {
  await supabase.auth.getClaims()
})

This is because:

  • onAuthStateChange runs inside an exclusive lock
  • If you call another API that tries to acquire the exclusive lock, the initial call will never finish, thereby never releasing the first lock, and no other Auth API can be called (across all tabs)

Multiple attempts were made to detect these situations but it's not easy as async functions don't track execution context in all environments properly.

This change adds a deprecation notice if the callback is an async function to discourage folks from using it, and hopefully make it a bit faster to realize why suddenly everything is frozen.

@hf hf requested review from a team as code owners October 2, 2025 10:06
@mandarini mandarini merged commit 87b997b into master Oct 2, 2025
23 checks passed
@mandarini mandarini deleted the hf/deprecation-notice-on-auth-state-change branch October 2, 2025 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants