Skip to content

Retry on timeout #149

Open
Open

Description

@atombrenner

Timeouts do not cause a retry. That is not clear from the documentation. Many examples look like the following (copied from quick start)

const api = createClient({ timeout: 5000, retries: 2 })
const response = await api('https://api.example.com/users')

I interpreted this as, if after 5s no response received, retry it two more times (three times in total).

But in fact, ffetch doesn't retry at all once the timeout is reached. I do not know if this is a bug or expected behavior :-)

Can you make it a bit clearer in the documentation what the exptected retry behavior for timeouts is?
Maybe elaborate a bit on the decision why you choose a certain behavior.

An example how to configure the client to retry on Timeouts can be helpful for new users.

The default decision when to retry seems to be implemented here:

export function shouldRetry(ctx: RetryContext): boolean {
const { error, response } = ctx
if (
error instanceof AbortError ||
error instanceof CircuitOpenError ||
error instanceof TimeoutError
)
return false
if (!response) return true // network error
return response.status >= 500 || response.status === 429
}

Activity

  1. atombrenner commented on Nov 17, 2026

    @atombrenner
    Author

    Update: It seems that the timeout option in createClient is the overall timeout, including all retries, and not the timeout per attempt. It seems to me it is impossible to have a retry-after-timeout with ffetch, can you confirm this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions