Repository navigation
fix(api): retryTransport body lifecycle and Retry-After parsing - #60
Merged
Merged
Conversation
…try-After - Drain and close every discarded response before retrying, including the 429 Retry-After path that previously skipped the close. - On exhausted retries return the last response with its body still open. - Parse Retry-After as delay-seconds or HTTP-date, capped at 60s. - Wait with a timer that aborts on request context cancellation. - Clone the request per attempt (with GetBody) instead of mutating it. - Inject sleep/clock in tests so retry tests no longer sleep in real time. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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 response-body handling and
Retry-Afterparsing inretryTransport(internal/api/retry.go).Retry-Afterpath, which used tocontinuepast the close.http.ParseTime). The wait is capped at 60s. A date in the past means retry immediately. Values that don't parse fall back to exponential backoff.time.Sleepis replaced by a timer +selectonreq.Context().Done(). Cancelling the context stops the wait and returnsctx.Err().req.ClonewithGetBodyset, so the caller's request is no longer modified.sleep/nowfields (nil means real time) keep the timing tests fast and deterministic. The old tests that waited in real time (≥1s) now use them. New httptest-based tests cover:parseRetryAfterCloses #31
Checklist
./scripts/ci.shpasses locally (orgo test -race ./...at minimum)feat:,fix:,docs:,chore:,ci:,test:)cu docs markdown --dir docs/site/commands) (no help text changed)🤖 Generated with Claude Code