Skip to content

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

Merged
mksglu merged 6 commits into
mksglu:nextfrom
flightlesstux:fix/insight-shutdown-kill
Apr 25, 2026
Merged

fix(insight): terminate dashboard when Claude/MCP exits#296
mksglu merged 6 commits into
mksglu:nextfrom
flightlesstux:fix/insight-shutdown-kill

Conversation

@flightlesstux

@flightlesstux flightlesstux commented Apr 16, 2026

Copy link
Copy Markdown
Contributor

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
@mksglu mksglu merged commit 517e4d4 into mksglu:next Apr 25, 2026
5 checks passed
@mksglu

mksglu commented Apr 25, 2026

Copy link
Copy Markdown
Owner

Thanks — clean child tracking + SIGTERM on shutdown, plus the INSIGHT_PARENT_PID watchdog covers SIGKILL/crash paths. Merged!

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