Skip to content

Fix: Polly retry policy not retrying CTS-triggered timeouts in PackageUploader#127

Open
elahmed-microsoft wants to merge 1 commit into
mainfrom
users/elahmed/fix-polly-retry-policy
Open

Fix: Polly retry policy not retrying CTS-triggered timeouts in PackageUploader#127
elahmed-microsoft wants to merge 1 commit into
mainfrom
users/elahmed/fix-polly-retry-policy

Conversation

@elahmed-microsoft
Copy link
Copy Markdown
Collaborator

Now instead uses the caller's cancellation token directly instead of a scoped CTS. A scoped CTS causes Polly to see the token as intentionally canceled on timeout, which prevents retries. HttpClient.Timeout (set to HttpUploadTimeoutMs) handles per-request timeouts at the transport layer, allowing Polly to retry normally.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adjusts request cancellation behavior so Polly can retry timeouts by avoiding per-request CancellationTokenSource timeouts and relying on transport-layer timeouts instead.

Changes:

  • Removed scoped CancellationTokenSource timeout from InitializeAssetAsync.
  • Passed the caller-provided cancellation token directly into HttpClient.SendAsync.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 161 to +163
using var req = CreateJsonRequest(HttpMethod.Post, $"{assetId}/initialize", deltaUpload, properties, XfusJsonSerializerContext.Default.UploadProperties);
using var cts = new CancellationTokenSource(_uploadConfig.HttpTimeoutMs);

var response = await _httpClient.SendAsync(req, cts.Token).ConfigureAwait(false);
var response = await _httpClient.SendAsync(req, ct).ConfigureAwait(false);
Comment on lines 161 to +163
using var req = CreateJsonRequest(HttpMethod.Post, $"{assetId}/initialize", deltaUpload, properties, XfusJsonSerializerContext.Default.UploadProperties);
using var cts = new CancellationTokenSource(_uploadConfig.HttpTimeoutMs);

var response = await _httpClient.SendAsync(req, cts.Token).ConfigureAwait(false);
var response = await _httpClient.SendAsync(req, ct).ConfigureAwait(false);
@elahmed-microsoft elahmed-microsoft marked this pull request as draft May 20, 2026 00:01
@elahmed-microsoft elahmed-microsoft marked this pull request as ready for review May 20, 2026 17:07
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.

2 participants