Skip to content

Gateway: avoid spurious Windows restart on unknown listener stale (#52044)#66627

Closed
ly85206559 wants to merge 1 commit into
openclaw:mainfrom
ly85206559:fix/52044-windows-restart-postcheck
Closed

Gateway: avoid spurious Windows restart on unknown listener stale (#52044)#66627
ly85206559 wants to merge 1 commit into
openclaw:mainfrom
ly85206559:fix/52044-windows-restart-postcheck

Conversation

@ly85206559

@ly85206559 ly85206559 commented Apr 14, 2026

Copy link
Copy Markdown
Contributor

Summary

  • split restart health into staleGatewayPids (diagnostics, includes Windows unknown-listener fallback) vs verifiedStaleGatewayPids (gateway-classified, actionable listeners)
  • only early-exit the restart wait and only kill/retry when verified stale PIDs exist, avoiding a third service.restart() from postRestartCheck on Windows (Bug: gateway restart spawns duplicate processes on Windows (3 windows) #52044)
  • align update-cli restart follow-up with the same rule and add regression coverage for diagnostic-only vs verified stale PID handling
  • fix stopped-free timing test to pin non-Windows platform so expectations are stable on Windows hosts

Test plan

  • pnpm test src/cli/update-cli.test.ts -t "does not re-restart after update|cleans verified stale pids after update"
  • pnpm test src/cli/daemon-cli/restart-health.test.ts src/cli/daemon-cli/lifecycle.test.ts src/cli/daemon-cli/status.gather.test.ts

Notes

  • The broader src/cli/update-cli.test.ts file still has an unrelated Windows portable-Git PATH test that is noisy on this host; the new restart-follow-up coverage passes.

@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes size: S labels Apr 14, 2026
@greptile-apps

greptile-apps Bot commented Apr 14, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR splits staleGatewayPids (diagnostics) from verifiedStaleGatewayPids (gateway-classified, actionable) on GatewayRestartSnapshot, and gates all kill/retry logic on the verified set. This prevents a spurious third service.restart() on Windows when the only stale entry comes from the unknown-listener fallback heuristic rather than a confirmed gateway process. The stopped-free timing test is also pinned to Linux so elapsed-time assertions stay deterministic on Windows hosts.

Confidence Score: 5/5

  • Safe to merge; the split is additive and backward-compatible, the fix is well-targeted, and all affected call sites are updated.
  • All remaining findings are P2 or below. The logic change is narrow, test coverage directly exercises the Windows-specific regression scenario, and the stopped-free timing fix resolves a pre-existing test instability on Windows hosts.
  • No files require special attention.

Reviews (1): Last reviewed commit: "Gateway: avoid spurious restart on Windo..." | Re-trigger Greptile

@ly85206559
ly85206559 force-pushed the fix/52044-windows-restart-postcheck branch 3 times, most recently from 4b63b8a to 49367ed Compare April 21, 2026 04:53
@ly85206559

Copy link
Copy Markdown
Contributor Author

Rebase onto main — conflicts resolved

Conflict: src/cli/daemon-cli/restart-health.test.ts (first commit vs main).

Cause: main added waitForStoppedFreeGatewayRestart() so non-Windows uses shared attempt logic; our branch still inlined waitForGatewayHealthyRestart with platform pinned to linux.

Resolution: Keep the helper from main and keep pinning process.platform to linux before the call so elapsed/sleep expectations stay stable on Windows hosts (same intent as the original PR).

Follow-up: lifecycle.test.tsfails restart when gateway remains unhealthy after the full timeout expected 60s, but on Windows postRestartHealthAttempts() uses the longer Windows window (180s in the message). Pinned platform to linux in that test so the assertion matches Linux/CI (same pattern as the test above it).

Verification: pnpm test on src/cli/daemon-cli/restart-health.test.ts, lifecycle.test.ts, and filtered update-cli tests for the new restart follow-up cases — all passed.

Branch force-pushed: 49367ed925 (3 commits: 2 original + 1 test fix).

…enclaw#52044)

- Split staleGatewayPids (diagnostics) from verifiedStaleGatewayPids (gateway-classified,
  actionable listeners); gate kill/retry and post-restart early-exit on verified stale PIDs
  only to avoid a third service.restart on Windows when only the unknown-listener fallback
  matches.
- Align update-cli restart follow-up with the same rule; add regression tests for
  diagnostic-only vs verified stale PID handling.
- Pin process.platform to linux in stopped-free and unhealthy-timeout restart tests so
  elapsed/sleep expectations stay stable on Windows hosts.
@ly85206559
ly85206559 force-pushed the fix/52044-windows-restart-postcheck branch from 5783172 to fa4a397 Compare April 25, 2026 01:58
@ly85206559 ly85206559 closed this Apr 26, 2026
@ly85206559
ly85206559 deleted the fix/52044-windows-restart-postcheck branch April 26, 2026 00:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant