Skip to content

[BUG] onRetry() called too many times #15

@rpaterson

Description

@rpaterson

What / Why

The onRetry callback is documented as "called whenever a retry is attempted", but in practice it appears to be called whenever a retry is attemptable. It is called even when no retry is attempted!

When

  • n/a

Where

  • n/a

How

Current Behavior

onRetry is called whenever retrying a response is attemptable, meaning it's not a POST and status code is 408, 420, 429, or >= 500. It is called even if retrying is completely disabled, or all the retries have been exhausted.

Steps to Reproduce

// should not print "we will retry!" but it does
fetch('https://httpstat.us/500', {
  retry: false,
  onRetry() {
    console.log('we will retry!')
  }
});

// should print "we will retry!" two times but prints it three times
fetch('https://httpstat.us/500', {
  retry: 2,
  onRetry() {
    console.log('we will retry!')
  }
});

Expected Behavior

onRetry should be called only if another request will actually happen, taking in to account the limit on the number of retries.

Who

  • n/a

References

  • n/a

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