Skip to content

Add configurable retry logic for transient failures#268

Open
ewimsatt wants to merge 1 commit intostevenvachon:mainfrom
ewimsatt:add-retry-logic
Open

Add configurable retry logic for transient failures#268
ewimsatt wants to merge 1 commit intostevenvachon:mainfrom
ewimsatt:add-retry-logic

Conversation

@ewimsatt
Copy link

Description

This PR implements retry logic for handling transient failures, as requested in #254.

Changes

  • Added three new configuration options:

    • maxRetries (default: 2) - Number of retry attempts
    • retryDelay (default: 100ms) - Initial delay between retries
    • retryStatusCodes (default: [408, 429, 500, 502, 503, 504]) - HTTP status codes that trigger retry
  • Implemented exponential backoff: delay * (2 ^ attemptNumber)

  • Retries on transient HTTP status codes (timeouts, rate limits, server errors)

  • Retries on network errors (ECONNRESET, ECONNREFUSED, ETIMEDOUT, etc.)

  • Preserves existing HEAD->GET retry behavior

Example Usage

const blc = require('broken-link-checker');

const options = {
  maxRetries: 3,           // Retry up to 3 times
  retryDelay: 200,         // Start with 200ms delay
  retryStatusCodes: [429, 500, 502, 503]  // Customize which codes to retry
};

Benefits

  • Reduces false positives from flaky servers
  • Handles temporary network issues gracefully
  • Configurable to match different use cases
  • No breaking changes - defaults maintain current behavior

Fixes #254

- Add maxRetries, retryDelay, retryStatusCodes options (defaults: 2 retries, 100ms delay)
- Implement exponential backoff (delay * 2^attempt)
- Retry on: 408, 429, 500, 502, 503, 504 status codes
- Retry on network errors: ECONNRESET, ECONNREFUSED, ETIMEDOUT, etc.
- Preserves existing HEAD->GET retry behavior

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add option to retry before failing

1 participant