Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auth-js does not handle Cloudflare Web server is down 521 error code correctly #1029

Open
2 tasks done
bergerkiller opened this issue Jan 28, 2025 · 0 comments
Open
2 tasks done
Labels
bug Something isn't working

Comments

@bergerkiller
Copy link

Bug report

  • I confirm this is a bug with Supabase, not with my own application.
  • I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

We have supabase running behind cloudflare proxy. We discovered that when the machine is offline and cloudflare can't reach it, cloudflare responds with a "Web server is down" page, with net error code 521.

Auth-JS does not consider error code 521 auth-retryable. This causes it to delete the user's session token due to downtime of the server.

To Reproduce

  1. Host supabase behind cloudflare
  2. Stop server or stop listening on port so cloudflare considers the server down
  3. Try to resume a user sessions with auth-js

Expected behavior

Keeps retrying, does not delete the session state

Additional context

It defines error codes that are retryable here: https://github.com/supabase/auth-js/blob/master/src/lib/fetch.ts#L38

And despite the comment suggesting otherwise, code 521 does not get retried: https://github.com/supabase/auth-js/blob/master/src/lib/fetch.ts#L46

Instead it falls all the way down to error.json(), fails because cloudflare sends html not json, then gets wrapped into AuthUnknown and then session gets nuked forever.

@bergerkiller bergerkiller added the bug Something isn't working label Jan 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant