openclaw - 💡(How to fix) Fix [Bug][Windows] openclaw update still hangs with stuck findstr on 2026.4.24 — prior fixes (#57682, #44693, #27802, #41804) are incomplete [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#72279Fetched 2026-04-27 05:32:06
View on GitHub
Comments
1
Participants
2
Timeline
2
Reactions
0
Timeline (top)
closed ×1commented ×1

Root Cause

Root cause (chain that links the four closed issues):

Fix Action

Fix / Workaround

The bug is structural, not a Windows-config edge case. The .bat is built on an assumption (schtasks /End releases the port) that gateway.cmd's shape contradicts. Patching windowsHide on the parent (#44693) doesn't help the children. Fixing the polling loop in isolation (#57682) doesn't help when the port can't be released. They have to be fixed together.

User-side workaround that fully bypasses today: openclaw update --no-restart, then restart by hand (schtasks /End + kill any orphan node on 18789 + schtasks /Run). Wrapping that in a personal openclaw-update.cmd shim makes it a drop-in replacement for openclaw update.

Code Example

ProcessId  ParentProcessId  Name         CommandLine
10164      36140            cmd.exe      cmd.exe /d /s /c %TEMP%\openclaw-restart-1777218587016.bat
2460       10164            findstr.exe  findstr /R /C:":18789 .*LISTENING"
19576      34768            node.exe     ...openclaw\dist\index.js gateway --port 18789

---

start "" /b "C:\Program Files\nodejs\node.exe" ...openclaw\dist\index.js gateway --port 18789 >nul 2>&1
   exit /b 0

---

for /f "tokens=5" %%P in ('netstat -ano ^| findstr /R /C:":18789 .*LISTENING"') do (
     taskkill /F /PID %%P
     goto port_released
   )
RAW_BUFFERClick to expand / collapse

Hitting this on openclaw 2026.4.24 (Windows 11 Pro 26200, Node 22), one day after #57682 was closed as completed. The persistent visible findstr /R /C:":18789 .*LISTENING" window symptom is unchanged. #44693, #27802, and #41804 were also closed as completed but are clearly still in play — they're three symptoms of the same broken update→restart contract.

Repro: openclaw update from any terminal. The detached %TEMP%\openclaw-restart-<ts>.bat spawns. findstr window appears and never closes. Gateway eventually restarts via the force-kill fallback in some runs but the cmd+findstr pair stays alive. del %~f0 at the end of the .bat is never reached.

Concrete evidence from a live run:

ProcessId  ParentProcessId  Name         CommandLine
10164      36140            cmd.exe      cmd.exe /d /s /c %TEMP%\openclaw-restart-1777218587016.bat
2460       10164            findstr.exe  findstr /R /C:":18789 .*LISTENING"
19576      34768            node.exe     ...openclaw\dist\index.js gateway --port 18789

Both cmd 10164 and findstr 2460 were still alive 4+ minutes after spawn. Gateway log shows restart attempt source=update target=OpenClaw Gateway with no restart done line — the script never reached :port_released.

Root cause (chain that links the four closed issues):

  1. ~/.openclaw/gateway.cmd (the action of the OpenClaw Gateway scheduled task) does:

    start "" /b "C:\Program Files\nodejs\node.exe" ...openclaw\dist\index.js gateway --port 18789 >nul 2>&1
    exit /b 0

    The cmd action exits immediately, so the scheduled task is no longer in a "running" state. Node is orphaned from the task — there's no parent/child link.

  2. The post-update restart .bat from dist/update-cli-*.js::prepareRestartScript calls schtasks /End /TN "OpenClaw Gateway" to release the port. The task isn't running (per #1), so /End is a no-op. The orphan node still holds 18789. This is what #27802 was about; closing it didn't fix the underlying shape of gateway.cmd.

  3. The polling loop (netstat | findstr ":18789 .*LISTENING") never sees the port released. After 10 attempts (~10s) it falls through to force_kill_listener:

    for /f "tokens=5" %%P in ('netstat -ano ^| findstr /R /C:":18789 .*LISTENING"') do (
      taskkill /F /PID %%P
      goto port_released
    )

    On some configs (likely under AV real-time scanning of findstr.exe in a piped for /f) this subshell deadlocks — findstr stays alive forever, cmd never exits, .bat never del'd. This is the visible-hanging symptom from #57682.

  4. Even when the for/f doesn't deadlock, the children (timeout /t, netstat, findstr, taskkill, schtasks) flash visible consoles. Parent cmd is spawned with windowsHide: true (update-cli line 619), but windowsHide doesn't propagate to descendant console-creating processes. This is #44693.

The bug is structural, not a Windows-config edge case. The .bat is built on an assumption (schtasks /End releases the port) that gateway.cmd's shape contradicts. Patching windowsHide on the parent (#44693) doesn't help the children. Fixing the polling loop in isolation (#57682) doesn't help when the port can't be released. They have to be fixed together.

Suggested fixes (any one helps; combining is cleanest):

  • (a) Fix gateway.cmd so the scheduled task actually owns the gateway process. Replace start "" /b node ... & exit /b 0 with foreground exec: "C:\Program Files\nodejs\node.exe" ...index.js gateway --port 18789 (no start /b, no exit). Then schtasks /End reliably terminates the listener. This single change makes the polling loop exit in <1s on every Windows machine and resolves #27802 directly.
  • (b) Replace the polling .bat with PowerShell. Use Get-NetTCPConnection -LocalPort 18789 -State Listen + Stop-Process instead of netstat | findstr | for /f | taskkill. PowerShell handles pipes deterministically and runs hidden cleanly with -WindowStyle Hidden. Drops both the flicker and the deadlock surface.
  • (c) Move the port-wait + kill logic into Node (in update-cli) before spawning the detached helper. Helper then only starts the task. Smaller scripts → smaller bug surface.

Happy to send a PR for (a)+(b) if a maintainer flags which direction is acceptable.

User-side workaround that fully bypasses today: openclaw update --no-restart, then restart by hand (schtasks /End + kill any orphan node on 18789 + schtasks /Run). Wrapping that in a personal openclaw-update.cmd shim makes it a drop-in replacement for openclaw update.

extent analysis

TL;DR

The most likely fix involves modifying the gateway.cmd script to ensure the scheduled task owns the gateway process, replacing the polling batch script with PowerShell, or moving the port-wait and kill logic into Node.

Guidance

  • Fix gateway.cmd: Replace start "" /b node ... & exit /b 0 with a foreground execution of the Node process to ensure schtasks /End can reliably terminate the listener.
  • Replace polling with PowerShell: Use Get-NetTCPConnection and Stop-Process to deterministically handle pipes and run hidden, reducing the bug surface.
  • Move logic to Node: Integrate the port-wait and kill logic into the Node update-cli before spawning the detached helper, simplifying scripts and reducing potential bugs.
  • User-side workaround: Utilize openclaw update --no-restart, then manually restart with schtasks /End, kill any orphaned Node process, and schtasks /Run, which can be automated in a personal openclaw-update.cmd shim.

Example

:: Modified gateway.cmd
"C:\Program Files\nodejs\node.exe" ...index.js gateway --port 18789

Notes

The provided solutions aim to address the structural issue causing the persistent visible findstr window and the failure of the update-restart contract. Each suggested fix targets a different aspect of the problem, allowing for a combined or individual approach to resolving the issue.

Recommendation

Apply workaround (a) Fix gateway.cmd as it directly addresses the root cause of the issue by ensuring the scheduled task owns the gateway process, making schtasks /End effective. This change is fundamental and can be combined with other fixes for a cleaner solution.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING