-
Notifications
You must be signed in to change notification settings - Fork 267
Fixes context cancellation issue #6536
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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