fix(daemon): report Windows SIGTERM daemon exits as forced

Merged
GA
3d ago
+69-14

Summary

On Windows, process.kill(pid, 'SIGTERM') calls TerminateProcess immediately without running Node signal handlers or writing daemon-shutdown.json, yet stopDaemonProcess reported 'graceful'.

  • packages/daemon-contracts/src/daemon-process.ts: signalExitMode() maps SIGTERM on win32 to 'forced' and preserves previousExitMode if the daemon exits before SIGKILL.
  • src/__tests__/daemon-exit-wait.test.ts and src/__tests__/daemon-registration-owner.test.ts: parameterize linux/win32 signal exit modes and match manual stop expectations on win32 (forced / unknown cleanup confidence).
  • src/commands/schema/cli-help.ts and website/docs/docs/commands.md: qualify the 75 s daemon stop teardown grace as non-Windows and state that Windows force-terminates (mode: "forced", cleanupConfidence: "unknown").

Touched files: 5 (+69 / -14). Rebased onto origin/main (d1ace8139 at c47c1af00); earlier prototype archived at archive/pr-4659-rpc-shutdown (d409073d1). Context: https://github.com/e2e-inc/e2e/issues/1723 (client release in https://github.com/e2e-inc/e2e/pull/1900; Windows graceful shutdown tracked in https://github.com/callstack/agent-device/issues/4822).

Before / after

Windows 11 session list --json -> daemon stop --json:

  • Base (bfc09800b): "mode": "graceful", "cleanupConfidence": "unknown", "The graceful shutdown report is unavailable..."
  • Head (c47c1af00): "mode": "forced", "cleanupConfidence": "unknown", "The daemon was force-killed before provider lease state could be finalized..."

Validation

Tested at c47c1af00 on Windows 11 (globalSetup skipped due to ps not found in PATH):

  • daemon-exit-wait.test.ts 33/33, cli-help-topics.test.ts 23/23, cli-help.test.ts 29/29, command-doc-coverage.test.ts 6/6.
  • check:quick, check:production-exports, check:bundle-owner-files, check:daemon-wire-compat, layering, di-seams, check-doc-prose, command-docs --check, pnpm build, smoke-daemon-clean.test.ts 3/3.
  • CI/risks: daemon-exit-wait.test.ts mocks process.platform; live win32 exit verified by CLI and smoke-daemon-clean.test.ts.