Repository navigation
fix(http): back off 2^attempt when a 429's Retry-After can't be parsed - #136
Closed
Ankur Gupta (ankur-pattern) wants to merge 2 commits into
Closed
Ankur Gupta (ankur-pattern) wants to merge 2 commits into
Ankur Gupta (ankur-pattern) wants to merge 2 commits into
Conversation
Ankur Gupta (ankur-pattern)
force-pushed
the
retry-after-backoff-fallback
branch
from
October 28, 2026 09:23
0788aaa to
08cdfab
Compare
Amit Malakar (amitmalakariitb)
approved these changes
Oct 28, 2026
Author
|
Closing per review: Caterpillar already honors a valid Retry-After, and our callers (rate-gate, Amazon) never send an unparseable one, so this isn't needed. |
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.
Summary
Fixes the
429backoff in thehttptask whenRetry-Aftercan't be used. Previously, a429with aRetry-Afterheader that didn't parse as seconds (for example an HTTP date, or a negative value) returned fromhandleBackoffwithout sleeping. Values like5mor1uwere worse:time.ParseDuration(value + "s")read them as 5ms and 1µs. The next attempt then fired immediately, using upmax_retrieswithin milliseconds. It now falls back to the existing2^attemptbackoff, the same as a429with noRetry-After.A valid
Retry-After(delay-seconds, a non-negative integer per RFC 9110) is honored exactly as before. No config changes.Changes
http/retry.go: newretryAfter(response)returns theRetry-Afterdelay for a429when the header is a non-negative integer number of seconds (strconv.ParseUint, surrounding spaces allowed).handleBackoffsleeps that delay when it's valid, and otherwise sleeps2^attempt.Testing
go vet -copylocks=false ./...andgo test -race ./...pass locally, the same as CI.retryAfter(valid, padded, missing, negative, unparseable,5m,1u,1.5, HTTP date, non-429, nil response) and the429sleep inhandleBackoff(validRetry-Afterhonored; unparseable and missing both back off2^attempt).Replaces #135, which also added
max_throttle_retries; that part isn't needed.