fix(http): add exponential backoff for rate limiting (429 errors)#457
Open
YonghaoZhao722 wants to merge 1 commit intoopenclaw:mainfrom
Open
fix(http): add exponential backoff for rate limiting (429 errors)#457YonghaoZhao722 wants to merge 1 commit intoopenclaw:mainfrom
YonghaoZhao722 wants to merge 1 commit intoopenclaw:mainfrom
Conversation
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>
Contributor
|
@YonghaoZhao722 is attempting to deploy a commit to the Amantus Machina Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 secondmaxTimeout: 8000- Max delay capped at 8 secondsfactor: 2- Exponential multiplier (1s → 2s → 4s...)randomize: true- Adds jitter to prevent thundering herdonFailedAttempt- Logs retry attempts for debuggingChanges
Modified
packages/clawdhub/src/http.ts:createRetryOptions()helper function{ retries: 2 }with backoff configurationBackwards 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
Last reviewed commit: 2d93733
(2/5) Greptile learns from your feedback when you react with thumbs up/down!