Skip to content

Conversation

@mandarini
Copy link
Contributor

Summary

  • Adds failOnNetworkError option to prevent silent fallback to anon key during network failures
  • When enabled, throws instead of silently degrading auth, giving apps clear error handling
  • Backward compatible: defaults to false (current behavior)

Problem

During network issues (Cloudflare outages, DNS failures, timeouts), getSession() returns { session: null, error }. The client ignores the error and uses the anon key, causing:

  • RLS policies with auth.uid() = user_id to fail (auth.uid() is NULL)
  • Users receive cryptic 406 errors instead of network errors

Solution

const supabase = createClient(url, key, {
  auth: { failOnNetworkError: true }
})

@mandarini mandarini self-assigned this Dec 3, 2025
@github-actions github-actions bot added the supabase-js Related to the supabase-js library. label Dec 3, 2025
@mandarini mandarini force-pushed the feat/fail-on-network-error branch from 85624b6 to f19c66c Compare December 3, 2025 10:31
@mandarini mandarini force-pushed the feat/fail-on-network-error branch from f19c66c to cded2de Compare December 3, 2025 10:32
@mandarini mandarini marked this pull request as ready for review December 3, 2025 10:33
@mandarini mandarini requested a review from a team as a code owner December 3, 2025 10:33
@coveralls
Copy link

coveralls commented Dec 3, 2025

Coverage Status

coverage: 80.691% (-0.5%) from 81.176%
when pulling cded2de on feat/fail-on-network-error
into af85057 on master.

@mandarini
Copy link
Contributor Author

Closing after discussion with @hf

@mandarini mandarini closed this Dec 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

supabase-js Related to the supabase-js library.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants