From 271313b03618fc15515bdeef3f9f4b130a6ffa1e Mon Sep 17 00:00:00 2001 From: Ben McClelland Date: Sat, 28 Feb 2026 16:04:37 -0800 Subject: [PATCH] fix: azure close download body in CopyObject to prevent resource leak When copying between two different Azure blobs, the source download stream body was only consumed by PutObject but never explicitly closed. If PutObject or any subsequent step returned an error, the underlying HTTP connection held by the Azure SDK was never released, leaking both the connection and any internal SDK retry goroutines attached to it. Added a deferred close on downloadResp.Body immediately after the successful DownloadStream call to ensure the body is always drained and released regardless of the outcome. --- backend/azure/azure.go | 1 + 1 file changed, 1 insertion(+) diff --git a/backend/azure/azure.go b/backend/azure/azure.go index ecaaf91e..2efb015f 100644 --- a/backend/azure/azure.go +++ b/backend/azure/azure.go @@ -1042,6 +1042,7 @@ func (az *Azure) CopyObject(ctx context.Context, input s3response.CopyObjectInpu if err != nil { return s3response.CopyObjectOutput{}, azureErrToS3Err(err) } + defer downloadResp.Body.Close() pInput := s3response.PutObjectInput{ Body: downloadResp.Body,