Skip to content

Backoff upon error during auto refresh #333

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

Closed
pixtron opened this issue Jul 28, 2022 · 3 comments
Closed

Backoff upon error during auto refresh #333

pixtron opened this issue Jul 28, 2022 · 3 comments
Labels

Comments

@pixtron
Copy link
Contributor

pixtron commented Jul 28, 2022

Bug report

Describe the bug

Backoff during auto refresh upon network failure fails in 1.23.0-next.

To Reproduce

  1. clone the repro
  2. npm install
  3. npm start
  4. Signup with email and password (or login if you already have an account)
  5. Disable all network interfaces
  6. Wait 2 minutes until token expires and auto refresh is triggered

The refresh request fails due to the client being offline. The client does not backoff and retry with further requests.

Expected behavior

The client should backoff and retry to refresh the token.

Suggested fix

This regression seems to have been introduced in 1.23.0-next in lib/fetch.ts with #301.

  1. Introduce a new Error AuthNetworkFailureError exends AuthError
  2. Throw AuthNetworkFailureError instead of AuthUnknownError. Fetch only throws on a network error (unfortunately there seems to be no way to distinguish between network errors and CORS though).
  3. Replace the check error?.message === NETWORK_FAILURE.ERROR_MESSAGE with error instanceof AuthNetworkFailureError
  4. Remove constant NETWORK_FAILURE.ERROR_MESSAGE

System information

  • OS: NA
  • Browser: NA
  • Version of supabase-js: NA
  • Version of gotrue-js: 1.23.0-next.6
  • Version of Node.js: NA

Additional context

The same mal function can probably be observed in _recoverAndRefresh.

@github-actions
Copy link
Contributor

🎉 This issue has been resolved in version 1.23.0-next.17 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions
Copy link
Contributor

🎉 This issue has been resolved in version 2.0.0-rc.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@kangmingtay
Copy link
Member

closing this since it's been resolved by the PRs above! thanks @pixtron once again :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants