Skip to content

Comments

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

Open
YonghaoZhao722 wants to merge 1 commit intoopenclaw:mainfrom
YonghaoZhao722:fix/rate-limit-exponential-backoff
Open

fix(http): add exponential backoff for rate limiting (429 errors)#457
YonghaoZhao722 wants to merge 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!

Add exponential backoff with jitter to pRetry configuration
to handle 429 rate limit errors gracefully.

- minTimeout: 1000ms (initial delay)
- maxTimeout: 8000ms (maximum delay)
- factor: 2 (exponential multiplier)
- randomize: true (adds 0-500ms jitter)
- onFailedAttempt: logs retry attempts for debugging

This fixes the issue where rapid retries without delay
cause repeated rate limiting failures.

Co-authored-by: Claude <claude@anthropic.com>
Co-authored-by: Clawdbot <clawdbot@openclaw.ai>
@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.

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.

1 participant