Skip to content

fix(gateway): handle Windows OpenClaw process exit error during in-process restarts#794

Merged
hazeone merged 2 commits intomainfrom
fix/windows_openclaw_process_exit_error
Apr 8, 2026
Merged

fix(gateway): handle Windows OpenClaw process exit error during in-process restarts#794
hazeone merged 2 commits intomainfrom
fix/windows_openclaw_process_exit_error

Conversation

@hazeone
Copy link
Copy Markdown
Contributor

@hazeone hazeone commented Apr 8, 2026

Summary

Fix gateway startup failures on Windows caused by in-process restarts (WS close code 1012). When the Gateway restarts internally, its UtilityProcess remains alive but the WebSocket server is temporarily unavailable. The old code would misidentify this as "no existing gateway," attempt to free the port (which never becomes free), and then spawn a duplicate process.

Key changes:

  • Add hasOwnedProcess() hook so the startup orchestrator can detect a still-alive owned process and wait for it to become ready instead of spawning a duplicate.
  • Improve GatewayManager.restart() to re-enable auto-reconnect recovery when start() fails after stop(), preventing the gateway from dying permanently.
  • Replace the inline WebSocket probe in findExistingGatewayProcess with the reusable probeGatewayReady() helper, which waits for the connect.challenge handshake message rather than just the open event — avoiding false positives from half-ready servers.

Related Issue(s)

Type of Change

  • Bug fix
  • New feature
  • Documentation
  • Refactor
  • Other

Validation

  • Added E2E spec (gateway-lifecycle.spec.ts) verifying app navigability during gateway disconnected/reconnecting states and status transitions.
  • Added unit tests for GatewayManager restart recovery, runGatewayStartupSequence owned-process path / retries / lifecycle-superseded handling, and probeGatewayReady challenge-based probe behavior.
  • Existing unit and E2E tests continue to pass.

Checklist

  • I ran relevant checks/tests locally.
  • I updated docs if behavior or interfaces changed.
  • I verified there are no unrelated changes in this PR.

Made with Cursor

hazeone and others added 2 commits April 8, 2026 11:32
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Haze <hazeone@users.noreply.github.com>
@hazeone hazeone merged commit 32d14b8 into main Apr 8, 2026
6 checks passed
@hazeone hazeone deleted the fix/windows_openclaw_process_exit_error branch April 8, 2026 04:06
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.

1 participant