make-fetch-happen
make-fetch-happen copied to clipboard
[BUG] onRetry() called too many times
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