Skip to content

fix(http): add exponential backoff for rate limiting (429 errors)#457

Merged
steipete merged 1 commit intoopenclaw:mainfrom
YonghaoZhao722:fix/rate-limit-exponential-backoff
Feb 25, 2026
Merged

fix(http): add exponential backoff for rate limiting (429 errors)#457
steipete merged 1 commit intoopenclaw:mainfrom
YonghaoZhao722:fix/rate-limit-exponential-backoff

Conversation

@YonghaoZhao722
Copy link

@YonghaoZhao722 YonghaoZhao722 commented Feb 21, 2026

Problem

The current pRetry configuration only specifies { retries: 2 } with no delay between attempts. When the server returns a 429 (rate limit) or 5xx error, the client immediately retries twice without backoff, causing repeated failures.

Solution

Add exponential backoff with jitter to all pRetry calls:

  • minTimeout: 1000 - Initial delay of 1 second
  • maxTimeout: 8000 - Max delay capped at 8 seconds
  • factor: 2 - Exponential multiplier (1s → 2s → 4s...)
  • randomize: true - Adds jitter to prevent thundering herd
  • onFailedAttempt - Logs retry attempts for debugging

Changes

Modified packages/clawdhub/src/http.ts:

  • Added createRetryOptions() helper function
  • Replaced all { retries: 2 } with backoff configuration
  • Each operation has a descriptive name for logging

Backwards Compatibility

Non-retryable errors (4xx except 429) still abort immediately via AbortError. Only 429 and 5xx errors trigger the backoff retry.


Co-authored-by: Claude claude@anthropic.com
Co-authored-by: Clawdbot clawdbot@openclaw.ai

Greptile Summary

Added exponential backoff configuration to all HTTP retry operations to handle rate limiting (429) and server errors (5xx) more gracefully. The implementation introduces a createRetryOptions() helper that configures p-retry with 1-8 second delays, exponential factor of 2, randomized jitter, and debug logging for retry attempts.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The change is well-scoped, adds proper exponential backoff to handle rate limiting gracefully, maintains existing error handling behavior (non-retryable errors still abort immediately), and has comprehensive test coverage that validates retry behavior for 429 errors and timeouts
  • No files require special attention

Last reviewed commit: 2d93733

(2/5) Greptile learns from your feedback when you react with thumbs up/down!

@vercel
Copy link
Contributor

vercel bot commented Feb 21, 2026

@YonghaoZhao722 is attempting to deploy a commit to the Amantus Machina Team on Vercel.

A member of the Team first needs to authorize it.

@steipete steipete force-pushed the fix/rate-limit-exponential-backoff branch from 2d93733 to 0ef9cbe Compare February 25, 2026 13:03
@steipete steipete merged commit 14a2fa8 into openclaw:main Feb 25, 2026
1 check failed
@steipete
Copy link
Collaborator

Landed via temp rebase onto main.

  • Gate: bun run lint && bun run test && bun run build && bun run docs:list
  • Land commit: 0ef9cbe
  • Merge commit: 14a2fa8

Thanks @YonghaoZhao722!

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.

2 participants