From 888c3bf9381cc91108f45a661d67918b0e26fab0 Mon Sep 17 00:00:00 2001 From: Shayne Boyer Date: Thu, 26 Feb 2026 22:24:37 -0500 Subject: [PATCH] fix: propagate context in remote build upload and log streaming - UploadBuildSource: use caller's ctx instead of context.Background() so blob upload respects cancellation (Ctrl+C) - streamLogs: replace bare time.Sleep with select on ctx.Done() so log polling responds to cancellation promptly Addresses finding 17 from Azure/azure-dev#6886 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- cli/azd/pkg/containerregistry/remote_build.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cli/azd/pkg/containerregistry/remote_build.go b/cli/azd/pkg/containerregistry/remote_build.go index 96f6f31f5ad..1408b4c7085 100644 --- a/cli/azd/pkg/containerregistry/remote_build.go +++ b/cli/azd/pkg/containerregistry/remote_build.go @@ -70,7 +70,7 @@ func (r *RemoteBuildManager) UploadBuildSource( } defer dockerContext.Close() - _, err = blobClient.UploadFile(context.Background(), dockerContext, nil) + _, err = blobClient.UploadFile(ctx, dockerContext, nil) if err != nil { return armcontainerregistry.SourceUploadDefinition{}, err } @@ -193,7 +193,11 @@ func streamLogs(ctx context.Context, blobClient *blockblob.Client, writer io.Wri } } - time.Sleep(1 * time.Second) + select { + case <-ctx.Done(): + return ctx.Err() + case <-time.After(1 * time.Second): + } continue }