Skip to content

Always retry fetching #1036

@typed-sigterm

Description

@typed-sigterm

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

It keeps trying to refresh the token when the server is unavailable. I can't get it to stop and show an error.

auth-js/src/GoTrueClient.ts

Lines 1836 to 1859 in daa2669

return await retryable(
async (attempt) => {
if (attempt > 0) {
await sleep(200 * Math.pow(2, attempt - 1)) // 200, 400, 800, ...
}
this._debug(debugName, 'refreshing attempt', attempt)
return await _request(this.fetch, 'POST', `${this.url}/token?grant_type=refresh_token`, {
body: { refresh_token: refreshToken },
headers: this.headers,
xform: _sessionResponse,
})
},
(attempt, error) => {
const nextBackOffInterval = 200 * Math.pow(2, attempt)
return (
error &&
isAuthRetryableFetchError(error) &&
// retryable only if the request can be sent before the backoff overflows the tick duration
Date.now() + nextBackOffInterval - startedAt < AUTO_REFRESH_TICK_DURATION_MS
)
}
)

To Reproduce

  1. Login to a working project
  2. Change supabase url to https://foo.example.com. simulate a server error

Expected behavior

Stop and throw an error after a certain number of attempts.

System information

  • OS: Windows
  • Browser (if applies): chrome
  • Version of supabase-js: 2.49.1
  • Version of Node.js: Bun 1.2.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions