Skip to content

Implement retry logic for HTTP requests with support for Retry-After header - #4636

Open
TingluoHuang wants to merge 1 commit into
mainfrom
users/tihuang/429
Open

Implement retry logic for HTTP requests with support for Retry-After header#4636
TingluoHuang wants to merge 1 commit into
mainfrom
users/tihuang/429

Conversation

@TingluoHuang

Copy link
Copy Markdown
Member

Prepare for supporting Retry-After header on 429 response.

@TingluoHuang
TingluoHuang requested a review from a team as a code owner August 14, 2026 16:08
Copilot AI lite review requested due to automatic review settings August 14, 2026 16:08
Comment thread src/Runner.Sdk/Util/UrlUtil.cs

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-After into a retry delay and applied it in VssHttpRetryMessageHandler.
  • Expanded default retryable HTTP status codes to include 429 TooManyRequests.
  • Updated runner action archive download retry logic to prefer Retry-After when 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 thread src/Sdk/Common/Common/VssNetworkHelper.cs
Comment thread src/Sdk/Common/Common/VssHttpRetryMessageHandler.cs
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));
}
Comment thread src/Runner.Sdk/Util/UrlUtil.cs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants