From eea0ddf932ce1f814e67cfbe8e676f664ebd71a9 Mon Sep 17 00:00:00 2001 From: Tomas Kracmar Date: Wed, 29 Jul 2026 12:05:30 +0200 Subject: [PATCH] fix(Update-KHDB): dispose HttpResponseMessage on download Invoke-DownloadWithRetry disposed the response stream and file handle but never the HttpResponseMessage itself returned by GetAsync, leaking one per shard download (the S3 code path already disposes its response object). Added a finally block per attempt to dispose it on both the success and retry/failure paths. Co-Authored-By: Claude Sonnet 5 --- Update-KHDB.ps1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Update-KHDB.ps1 b/Update-KHDB.ps1 index 6bb0526..c388b79 100644 --- a/Update-KHDB.ps1 +++ b/Update-KHDB.ps1 @@ -76,6 +76,7 @@ function Invoke-DownloadWithRetry { $retries = 5 $delay = 2 for ($attempt = 0; $attempt -lt $retries; $attempt++) { + $response = $null try { $response = $Client.GetAsync($Uri, [System.Net.Http.HttpCompletionOption]::ResponseHeadersRead).Result if (-not $response.IsSuccessStatusCode) { @@ -115,6 +116,8 @@ function Invoke-DownloadWithRetry { } else { throw } + } finally { + if ($response) { $response.Dispose() } } } }