hindsight icon indicating copy to clipboard operation
hindsight copied to clipboard

embed control center Stop and Restart skip shutdown for unhealthy daemons

Open Web4everyone32 opened this issue 1 month ago • 1 comments

Bug Description

The embed control-center service gates Stop and Restart on daemon_client.is_daemon_running, which checks whether /health responds successfully. An alive but busy/unhealthy daemon fails this probe. Stop then reports success without calling the manager's shutdown path; Restart proceeds without first stopping the existing process.

Steps to Reproduce

  1. Run an embed daemon and make its health endpoint unresponsive or return a non-200 status (for example, a busy process).
  2. Use Stop or Restart in the embed control center.
  3. Observe control_center/service.py: Stop returns early when is_daemon_running is false; Restart skips stop_daemon under the same condition.

Deterministic local reproduction: start the real ControlCenterHandler on a loopback socket; make the daemon health predicate return false and spy on stop_daemon; POST /api/profiles/default/daemon/stop or /restart. Neither invokes shutdown. A failed-shutdown stub is also bypassed by Restart, which reports success.

Expected Behavior

Always delegate explicit Stop/Restart to the existing daemon manager. Its stop method already checks port occupancy, safely handles an absent listener, and identifies owned daemon processes. Restart must not start again if shutdown fails.

Actual Behavior

Stop reports that the daemon was not running without sending a stop request. Restart bypasses shutdown and its failure result.

Version

1.1.0, commit 5a672f0cdb89f4a3b841770cce2036a5b28b799d

LLM Provider

Not applicable. Windows, Python 3.11.9; real control-center HTTP socket tests with the daemon lifecycle mocked. No LLM/database required.

Diagnosis and proposed fix

Remove the health-based precondition from Stop and Restart. The manager already contains the process-aware policy (including the lower-level fix documented for #3169), but the control-center service prevents it from running.

Fix pushed to Web4everyone32/hindsight branch fix/control-center-unhealthy-daemon-stop. Three regression cases fail before the fix; the fixed control-center suite passes 49 tests.

Web4everyone32 avatar Oct 26 '26 22:10 Web4everyone32

I prepared a fix for Stop/Restart skipping unhealthy daemons in PR #2 on my fork. Three regression cases reproduce the original bug, and all 49 control-center tests pass after the fix. Would a maintainer consider reviewing or cherry-picking it?

Web4everyone32 avatar Oct 26 '26 22:10 Web4everyone32