Skip to content

Commit

Permalink
docs: Comment on retry mechanism
Browse files Browse the repository at this point in the history
  • Loading branch information
MattCCC committed Dec 4, 2024
1 parent 6dfb7da commit 5a3f4e2
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/request-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -519,9 +519,11 @@ export function createRequestHandler(
const status = error?.response?.status || error?.status || 0;

if (
attempt === retries ||
!(!shouldRetry || (await shouldRetry(error, attempt))) ||
!retryOn?.includes(status)
// We check retries provided regardless of the shouldRetry being provided so to avoid infinite loops.
// It is a fail-safe so to prevent excessive retry attempts even if custom retry logic suggests a retry.
attempt === retries || // Stop if the maximum retries have been reached
!retryOn?.includes(status) || // Check if the error status is retryable
!(await shouldRetry?.(error, attempt)) // If shouldRetry is defined, evaluate it
) {
await processError<ResponseData>(error, fetcherConfig);

Expand Down

0 comments on commit 5a3f4e2

Please sign in to comment.