From 5c9a02320cf7d92f7c0a9b00838e07dfe93b0818 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 24 Jun 2026 20:52:52 +0000 Subject: [PATCH 1/2] Initial plan From e8fb076dca198197bbf23453d530bc2bfdb1e9a5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 24 Jun 2026 20:55:00 +0000 Subject: [PATCH 2/2] Bound package download duration with cancellation token timeout --- Program.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Program.cs b/Program.cs index 463696d..482a75a 100644 --- a/Program.cs +++ b/Program.cs @@ -981,11 +981,15 @@ static async Task DownloadAndInstallPackage(string displayName, string url, stri Logger.WriteSubProgress("Downloading from", url); DialogManager.Instance.NotifyDownloadStarted(displayName); - using var httpClient = new HttpClient(); + using var httpClient = new HttpClient + { + Timeout = Timeout.InfiniteTimeSpan + }; + using var timeoutCts = new CancellationTokenSource(TimeSpan.FromMinutes(10)); var authHeader = ConfigManager.Instance.Config.AuthorizationHeader; if (!string.IsNullOrEmpty(authHeader)) httpClient.DefaultRequestHeaders.TryAddWithoutValidation("Authorization", authHeader); - using var response = await httpClient.GetAsync(url); + using var response = await httpClient.GetAsync(url, HttpCompletionOption.ResponseHeadersRead, timeoutCts.Token); if (!response.IsSuccessStatusCode) { throw new Exception($"Download failed: {response.StatusCode}"); @@ -994,8 +998,8 @@ static async Task DownloadAndInstallPackage(string displayName, string url, stri // Ensure the file stream is completely closed before proceeding { await using var fileStream = File.Create(localPath); - await response.Content.CopyToAsync(fileStream); - await fileStream.FlushAsync(); + await response.Content.CopyToAsync(fileStream, timeoutCts.Token); + await fileStream.FlushAsync(timeoutCts.Token); } // fileStream is disposed here // Add a small delay to ensure file handle is released