Skip to content

Bound package download timeout across headers and streaming#11

Draft
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-review-comment-3470144242
Draft

Bound package download timeout across headers and streaming#11
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-review-comment-3470144242

Conversation

Copilot AI commented Jun 24, 2026

Copy link
Copy Markdown

The review identified that the intended 10-minute download timeout only covered response headers, while body streaming could stall indefinitely. This update applies a single timeout budget to the full download lifecycle.

  • Timeout semantics

    • Set HttpClient.Timeout to Timeout.InfiniteTimeSpan to avoid split timeout behavior when using streaming.
    • Added a 10-minute CancellationTokenSource and used it as the single timeout mechanism.
  • Download path update (Program.cs)

    • Switched to GetAsync(url, HttpCompletionOption.ResponseHeadersRead, token) so header fetch is cancellable by the same token.
    • Passed the same token to CopyToAsync and FlushAsync so stalled stream copy is also bounded.
using var httpClient = new HttpClient { Timeout = Timeout.InfiniteTimeSpan };
using var timeoutCts = new CancellationTokenSource(TimeSpan.FromMinutes(10));

using var response = await httpClient.GetAsync(
    url,
    HttpCompletionOption.ResponseHeadersRead,
    timeoutCts.Token);

await response.Content.CopyToAsync(fileStream, timeoutCts.Token);
await fileStream.FlushAsync(timeoutCts.Token);

Copilot AI changed the title [WIP] Fix code based on review comment 3470144242 Bound package download timeout across headers and streaming Jun 24, 2026
Copilot AI requested a review from rodchristiansen June 24, 2026 20:56
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