Closed
Description
Bug report
Describe the bug
Backoff during auto refresh upon network failure fails in 1.23.0-next.
To Reproduce
- clone the repro
- npm install
- npm start
- Signup with email and password (or login if you already have an account)
- Disable all network interfaces
- 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.
- Introduce a new Error
AuthNetworkFailureError exends AuthError
- Throw
AuthNetworkFailureError
instead ofAuthUnknownError
. Fetch only throws on a network error (unfortunately there seems to be no way to distinguish between network errors and CORS though). - Replace the check
error?.message === NETWORK_FAILURE.ERROR_MESSAGE
witherror instanceof AuthNetworkFailureError
- 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
.