Skip to content

fix(app): derive shutdown context from context.Background() instead of cancelled globalCtx#2242

Open
AnyCPU wants to merge 1 commit intocharmbracelet:mainfrom
AnyCPU:fix/shutdown_ctx_already_cancelled_1
Open

fix(app): derive shutdown context from context.Background() instead of cancelled globalCtx#2242
AnyCPU wants to merge 1 commit intocharmbracelet:mainfrom
AnyCPU:fix/shutdown_ctx_already_cancelled_1

Conversation

@AnyCPU
Copy link
Contributor

@AnyCPU AnyCPU commented Feb 16, 2026

  • I have read CONTRIBUTING.md.
  • I have created a discussion that was approved by a maintainer (for new features).

When the user presses Ctrl+C, signal.NotifyContext cancels globalCtx. Shutdown() then derives shutdownCtx from it.

A child of a cancelled context is born cancelled, so the 5-second timeout never takes effect. All context-dependent cleanup silently short-circuits:

  • shell.KillAll(shutdownCtx) — returns immediately, background shells not waited on
  • mcp.Close(shutdownCtx) — returns immediately, MCP sessions not closed

Fix

Use context.WithTimeout(context.Background(), 5*time.Second) so shutdown cleanup gets a live 5-second window.

@AnyCPU AnyCPU requested a review from a team as a code owner February 16, 2026 22:49
@AnyCPU AnyCPU requested review from aymanbagabas and meowgorithm and removed request for a team February 16, 2026 22:49
@AnyCPU
Copy link
Contributor Author

AnyCPU commented Feb 19, 2026

@caarlos0 could you by any chance take a look at this mr :-) a fix is simple but useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants