Skip to content

Backoff upon error during auto refresh #333

Closed
@pixtron

Description

@pixtron

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions