Repository navigation
Honour Retry-After on a GitHub rate limit [patch] - #388
Merged
Merged
Conversation
Only X-RateLimit-Reset was read, which on a secondary limit is the end of the primary hourly window, so a limit that asked for 60 s paused polling for the 10-minute cap. Use Retry-After when it is sent, X-RateLimit-Reset only when the primary budget is spent, and otherwise back off a minute. Part of #385 (the GitHub half). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW2nrCvY4DyoEF72Nk1
|
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.



Part of #385. This is the GitHub half; the Azure DevOps half is explained below and left open on the issue.
What was wrong
ParseRateLimitResetTimeread onlyX-RateLimit-Reset. On a secondary (abuse) limit that header is still the end of the primary hourly window, often 30–60 minutes away, and theRetry-AfterGitHub sends (typically 60 s) was ignored.GetRateLimitWaitTime()then paused every GitHub request for the 10-minute cap.Change
ParseRateLimitResetTimenow follows GitHub's guidance:Retry-Afterpresent: retry after that many seconds (an HTTP-date value is also accepted).X-RateLimit-Remaining: 0: wait untilX-RateLimit-Reset, as before.SecondaryRateLimitBackoff).A response with no headers still returns
null, so the existing incremental backoff applies.GitHubRateLimitResetTestscovers each acceptance case. The headline case is a 403 withRemaining: 4000,Reset: now+45mandRetry-After: 60, which now givesnow+60s.Not in this PR: the Azure DevOps 429
The issue suggests reading
Retry-Afteroff theVssServiceResponseException. That exception carries no response or headers; its only public members areHttpStatusCodeand the message. Capturing the header means adding aDelegatingHandlerto theVssConnectionpipeline that records the last 429'sRetry-After. That can't be checked without a live organization, since building a session authenticates against dev.azure.com, so it is noted on the issue rather than shipped untested.Verification
Retry-After, no-Retry-Aftersecondary and HTTP-date cases fail. The primary-reset case passes either way because that behaviour is unchanged. With the fix, all four pass.dotnet test --project BuildMonitor.Test: 147/147 pass.dotnet build -c Release: 0 warnings.Generated by Claude Code