Skip to content

Retry with exponential backoff on HTTP 429 (rate limiting) #1

@sujito00

Description

@sujito00

Problem

When X returns HTTP 429 (rate limited), all methods immediately fail and return an error. Users must manually re-run commands.

This is especially painful during pagination operations (search --all, bookmarks --all) where partial progress is lost.

Proposed solution

Add automatic retry with exponential backoff:

  • Detect 429 responses in fetchWithTimeout or a wrapper
  • Retry up to N times (default: 3) with exponential delay (1s, 2s, 4s)
  • Respect Retry-After header if present
  • Make max retries configurable via constructor option
const client = new XReaderClient({
  cookies: { ... },
  maxRetries: 3,    // default: 3
  retryDelay: 1000, // base delay in ms
});

Additional context

The paginated methods already have hardcoded sleeps (1000ms for search, 500ms for bookmarks), but these are preventive, not reactive. Both approaches should coexist.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions