Fixes context cancellation issue#6536
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes a context cancellation issue where stale cancelled contexts from previous workflow step executions could persist in the cobra command tree, causing "context canceled" errors in subsequent workflow steps (particularly during Bicep downloads after login in azd up).
Changes:
- Renamed
setContextRecursivelytoclearContextRecursivelywith updated implementation - Changed approach from setting
childCtxon all commands to clearing withcontext.TODO()before execution - Updated comments to explain the rationale for using
context.TODO()as a temporary placeholder
Azure Dev CLI Install InstructionsInstall scriptsMacOS/Linux
bash: pwsh: WindowsPowerShell install MSI install Standalone Binary
MSI
Documentationlearn.microsoft.com documentationtitle: Azure Developer CLI reference
|
Fixes #6530
Fix context cancellation affecting singletons
Problem
Singletons (like CLI tool wrappers) were capturing step-scoped contexts that get cancelled after each command step completes, causing "context canceled" errors in subsequent operations (e.g., deploy failing after provision).
Solution
Three-layer fix to prevent stale contexts from breaking singleton behavior:
main.go: Wrap root context with
context.WithoutCancel()to protect the entire command tree from external cancellation signalsEnsureInstalled pattern for CLI tools (
bicep,github,pack):*CliEnsureInstalled(ctx)method does I/O operations withsync.Oncefor thread-safe one-time initializationEnsureInstalledbefore first useroot.go: Clear context from cobra command tree in
PersistentPostRunEto prevent stale context references