Skip to content

[Bug][Windows] openclaw update spawns visible and hanging CMD window during gateway restart #57682

Description

@zhangxue1985122219

When running openclaw update on Windows, a visible CMD window with the title findstr /R /C:":18789 .*LISTENING" appears and often fails to close automatically, hanging indefinitely. This occurs during the service restart phase of the update process.

Root Cause Analysis

The issue stems from the temporary batch script generated by the update-cli subsystem (specifically in dist/update-cli-*.js and prepareRestartScript function).

  1. Sub-process Visibility: While the parent cmd.exe is spawned with windowsHide: true, the sub-processes invoked inside the .bat file (like for /f ... in ('findstr ...')) do not inherit this flag and spawn new visible console windows on some Windows configurations.
  2. Hanging Logic: The polling loop in the generated .bat file can enter a race condition or hang if netstat or findstr encounters a pipe error, causing the visible window to persist.

Environment

  • OS: Windows (win32)
  • OpenClaw Version: 2026.3.28 (and likely earlier versions)
  • Node.js Version: 20.x+

Reproduction Steps

  1. Run openclaw update on a Windows machine where the Gateway service is already running.
  2. Observe the update process reaching the "Restarting service..." step.
  3. A black CMD window titled findstr ... will pop up and stay on the desktop.

Expected Behavior

The restart process should be entirely silent and backgrounded without spawning any visible console windows.

Proposed Fixes

  1. Use PowerShell for Windows: Replace the temporary .bat file with a .ps1 script using native commands like Get-NetTCPConnection, which are more stable and easier to run hidden.
  2. Creation Flags: In runRestartScript, use the CREATE_NO_WINDOW (0x08000000) flag in spawn options to ensure the entire process tree is hidden.
  3. Refactor Polling: Implement the port-wait logic directly in Node.js before spawning the detached restart process to minimize complexity in the shell script.

Temporary Workaround for Users

Run update with --no-restart: openclaw update --no-restart and then manually restart the gateway.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions