Implement retry logic for HTTP requests with support for Retry-After header - #4636
Open
TingluoHuang wants to merge 1 commit into
Open
Implement retry logic for HTTP requests with support for Retry-After header#4636TingluoHuang wants to merge 1 commit into
TingluoHuang wants to merge 1 commit into
Conversation
TingluoHuang
force-pushed
the
users/tihuang/429
branch
from
August 14, 2026 16:09
46a4488 to
a732eb6
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the HTTP retry infrastructure to honor Retry-After on throttling responses (429), and wires that behavior into both the SDK retry handler and the runner’s action archive download path.
Changes:
- Added parsing/conversion of
Retry-Afterinto a retry delay and applied it inVssHttpRetryMessageHandler. - Expanded default retryable HTTP status codes to include
429 TooManyRequests. - Updated runner action archive download retry logic to prefer
Retry-Afterwhen throttled.
Show a summary per file
| File | Description |
|---|---|
| src/Sdk/WebApi/WebApi/OAuth/VssOAuthTokenHttpClient.cs | Adjusts retry option initialization for OAuth token HTTP calls. |
| src/Sdk/Common/Common/VssNetworkHelper.cs | Adds helper to parse Retry-After into a bounded retry delay. |
| src/Sdk/Common/Common/VssHttpRetryOptions.cs | Includes 429 TooManyRequests in default retryable status codes. |
| src/Sdk/Common/Common/VssHttpRetryMessageHandler.cs | Reads Retry-After and uses it to compute retry backoff. |
| src/Sdk/Common/Common/Utility/HttpHeaders.cs | Adds Retry-After header constant. |
| src/Runner.Worker/ActionManager.cs | Prefers Retry-After backoff for 429 during action archive download retries. |
| src/Runner.Sdk/Util/UrlUtil.cs | Adds GetRetryAfter helper to extract the header value. |
Review details
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Suppressed comments (2)
src/Sdk/Common/Common/VssHttpRetryMessageHandler.cs:139
- Per-request retry option overrides are not fully honored here: max backoff is taken from m_retryOptions instead of the effective retryOptions for this request. This can produce a larger/smaller delay than the caller intended when overriding MaxBackoff.
// Honor the Retry-After header (delay in seconds or an absolute date/time) when present,
// otherwise fall back to the standard exponential backoff.
var retryAfterDelay = VssNetworkHelper.ConvertRetryAfterToTimeSpan(retryAfterHeader, minBackoff, m_retryOptions.MaxBackoff);
if (retryAfterDelay.HasValue)
{
src/Sdk/Common/Common/VssHttpRetryMessageHandler.cs:145
- Per-request retry option overrides are not fully honored: exponential backoff uses m_retryOptions.MaxBackoff/BackoffCoefficient instead of the effective retryOptions for this request.
{
backoff = BackoffTimerHelper.GetExponentialBackoff(attempt, minBackoff, m_retryOptions.MaxBackoff, m_retryOptions.BackoffCoefficient);
}
- Files reviewed: 7/7 changed files
- Comments generated: 4
- Review effort level: Lite
Comment on lines
+1703
to
+1707
| // We are being throttled, use the Retry-After header (if provided) to decide backoff time. | ||
| // We will back off between 10s and 10min when Retry-After is provided. | ||
| var retryAfterHeader = UrlUtil.GetRetryAfter(response.Headers); | ||
| retryAfter = VssNetworkHelper.ConvertRetryAfterToTimeSpan(retryAfterHeader, TimeSpan.FromSeconds(10), TimeSpan.FromMinutes(10)); | ||
| } |
luketomlinson
approved these changes
Aug 14, 2026
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.
Prepare for supporting
Retry-Afterheader on 429 response.