Skip to content

fix(insight): terminate dashboard when Claude/MCP exits#296

Open
flightlesstux wants to merge 6 commits intomksglu:nextfrom
flightlesstux:fix/insight-shutdown-kill
Open

fix(insight): terminate dashboard when Claude/MCP exits#296
flightlesstux wants to merge 6 commits intomksglu:nextfrom
flightlesstux:fix/insight-shutdown-kill

Conversation

@flightlesstux
Copy link
Copy Markdown
Contributor

@flightlesstux flightlesstux commented Apr 16, 2026

Summary

  • ctx_insight dashboard was spawned detached: true + unref() and never tracked, so it kept running after Claude closed
  • Track the child in _insightChild and SIGTERM it from shutdown() (also kills prior child on re-invocation)
  • Pass INSIGHT_PARENT_PID and add a 5s process.kill(ppid, 0) watchdog in insight/server.mjs for SIGKILL / crash / prior-session-orphan paths

Why

User expectation: closing Claude should close the dashboard. Current behavior leaked a node process + bound port across sessions.

Test plan

  • Launch Claude, run ctx_insight, confirm dashboard up
  • Exit Claude cleanly, confirm port 4747 free within ~1s
  • kill -9 the MCP process, confirm dashboard self-exits within ~5s (watchdog)
  • Re-run ctx_insight in same session, confirm old child killed before new one spawns

github-actions Bot and others added 4 commits April 15, 2026 18:22
The ctx_insight dashboard was spawned with `detached: true` + `unref()`
and never tracked, so it outlived the MCP process and kept running in
the background after Claude closed.

- Track the spawned child in `_insightChild` and SIGTERM it from
  `shutdown()` (also kills it on re-invocation within the same session).
- Pass `INSIGHT_PARENT_PID` and add a 5s watchdog in `insight/server.mjs`
  that exits on `ESRCH` — covers SIGKILL / crash paths where `shutdown()`
  cannot run, plus orphans from prior sessions.
- Update skill doc to note auto-cleanup.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@mksglu mksglu changed the base branch from main to next April 16, 2026 23:18
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