test: make daemon disconnect checks independent of startup speed

Merged
BO
3d ago
+50-10

The early-disconnect regression test now reaches proxy attachment before its short idle deadline can fire, and prints daemon socket/client/shutdown state if the process stays alive.

A test-only preload skips the initial startup idle arm; the real timer still starts when the last registered client disconnects. The test retains its raw connection closing before client hello, eight-second exit requirement and writer-lock cleanup assertion. Its outer deadline now covers the sequential startup waits. The separate idle-exit tests retain their original startup behavior.

Real watcher-startup cases now have explicit 30-second outer deadlines rather than Vitest’s five-second default. These include initialization and child startup before the unchanged readiness deadlines. File-level temp cleanup reuses the existing bounded removal helper after test teardown. No production daemon behavior changes; the earlier Windows post-disconnect exit failure remains unexplained.

Validation: both changed suites passed 84/84 tests on Node 24/Linux after the final preload-path and deadline changes. TypeScript/assets/viewer build, fixture syntax, agent-doc guard and whitespace checks passed. The test floor guard flags the exit assertion’s move into a diagnostic variable; the same call, deadline and true assertion remain. The follow-up deadline correction passed all 60 runtime-control tests on Node 24/Linux. The first cross-platform CI run passed Linux and macOS. Windows passed the disconnect regression but failed two remaining watcher cases at Vitest’s 5,000 ms default (5,036 ms and 5,020 ms). Those cases and siblings with the same startup path now use the explicit outer deadline. A new Windows/macOS/Linux lifecycle run is required before landing.

README “About this fork” rows checked: tests only; no feature, language, runtime support or measured-number row changes. Related earlier lifecycle work: #398 and #399.

Summary by CodeRabbit

  • Tests
    • Added checks for daemon shutdown after a client disconnects, with diagnostic logging to help investigate failures.
    • Extended timeouts for daemon and runtime-control tests to accommodate longer-running test environments.
    • Temporary test directories are now cleaned up asynchronously after saved environment settings are restored.