Skip to content

retryOn should still honour the number of retries #94

Description

@AlexBroadbent

In the Example: Retry custom behavior code snippet from the readme, it would be assumed that also passing in a retries: 3 would mean that there would be at-most 3 attempts of the function. However, it would appear that's not the case as I found from running this setup:

fetchWithRetry(globalThis.fetch, { 
  retries: 3,
  retryDelay: 1000,
  retryOn(
    attempt: number,
    error: Error | null,
    response: Response | null,
  ): boolean {
    return error !== null || (response?.status && (response.status === 412 || response.status >= 500));
  }
});

It's only after coming back to the docs and seeing the Example: Retry custom behaviour with async example which has an if check on the attempt number that I realised the initial retries property is then overridden by retryOn.

Activity

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions