openclaw - 💡(How to fix) Fix Windows: CLI commands hang for 30-90s after output completes (event loop not exiting) [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

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#63227Fetched 2026-04-09 07:56:39
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0
Author
Participants

Root Cause

Root Cause Hypothesis

Fix Action

Workaround

PowerShell profile wrapper with timeout:

function openclaw {
    $job = Start-Job -ScriptBlock { openclaw @args } -ArgumentList $args
    $completed = Wait-Job $job -Timeout 5
    if ($completed) { Receive-Job $job; Remove-Job $job -Force }
    else { Write-Host "[openclaw] Timed out" -ForegroundColor Yellow; Receive-Job $job 2>$null; Stop-Job $job; Remove-Job $job -Force }
}

Code Example

# Fast path (no delay):
openclaw --version          # ~1s ✅

# Full initialization path (hangs):
openclaw help               # ~89s ❌
openclaw gateway status --no-probe  # ~36s ❌
openclaw status             # ~50s ❌

---

[552964ms] Service: Scheduled Task (registered)
[553014ms] File logs: \tmp\openclaw\openclaw-2026-04-08.log
[553066ms] Command: C:\nvm4w\nodejs\node.exe ...
...
[553662ms] Troubleshooting: https://docs.openclaw.ai/troubleshooting
-- all output printed within 800ms --
-- process then hangs for ~34 more seconds before exiting --

---

function openclaw {
    $job = Start-Job -ScriptBlock { openclaw @args } -ArgumentList $args
    $completed = Wait-Job $job -Timeout 5
    if ($completed) { Receive-Job $job; Remove-Job $job -Force }
    else { Write-Host "[openclaw] Timed out" -ForegroundColor Yellow; Receive-Job $job 2>$null; Stop-Job $job; Remove-Job $job -Force }
}
RAW_BUFFERClick to expand / collapse

Bug Description

On Windows 11, all openclaw CLI commands that go through the full initialization path hang for 30-90 seconds after all output has been printed, before the process finally exits. The actual command execution completes in under 1 second.

Environment

  • OS: Windows 11 Pro 10.0.26300 (x64)
  • OpenClaw: 2026.4.8 (9ece252)
  • Node.js: v22.22.2 (via nvm4w)
  • Shell: Git Bash / PowerShell / cmd.exe (all affected)

Reproduction

# Fast path (no delay):
openclaw --version          # ~1s ✅

# Full initialization path (hangs):
openclaw help               # ~89s ❌
openclaw gateway status --no-probe  # ~36s ❌
openclaw status             # ~50s ❌

Diagnosis

CPU profile shows near-zero CPU usage during hang

Ran with node --cpu-prof:

  • CPU time: 42ms
  • Wall-clock time: 34s
  • 99.9% of the time is I/O wait, not CPU work

Output completes instantly, process hangs after

Timestamped every line of openclaw gateway status --no-probe output:

[552964ms] Service: Scheduled Task (registered)
[553014ms] File logs: \tmp\openclaw\openclaw-2026-04-08.log
[553066ms] Command: C:\nvm4w\nodejs\node.exe ...
...
[553662ms] Troubleshooting: https://docs.openclaw.ai/troubleshooting
-- all output printed within 800ms --
-- process then hangs for ~34 more seconds before exiting --

Spawning via Node.js spawn() exits immediately

When the same command is spawned as a child process with piped stdio, it exits in 3ms. The hang only occurs when running directly from a terminal.

Individual operations measured as fast

  • schtasks /Query (full): ~1s
  • schtasks /Query /TN "OpenClaw Gateway": ~100ms
  • PowerShell Get-NetTCPConnection: ~1.2s
  • netstat -ano -p tcp: ~74ms
  • curl http://127.0.0.1:18789/: ~4ms
  • Module loading: ~500ms

No network connections or zombie child processes

Checked during the hang period — no outbound connections from the openclaw PID, no zombie PowerShell/cmd child processes.

Root Cause Hypothesis

Something in the CLI initialization phase (likely plugin loading, config loading, or an uncleared timer/Promise) keeps the Node.js event loop alive for ~30s after the command completes. This appears to be Windows-specific.

Workaround

PowerShell profile wrapper with timeout:

function openclaw {
    $job = Start-Job -ScriptBlock { openclaw @args } -ArgumentList $args
    $completed = Wait-Job $job -Timeout 5
    if ($completed) { Receive-Job $job; Remove-Job $job -Force }
    else { Write-Host "[openclaw] Timed out" -ForegroundColor Yellow; Receive-Job $job 2>$null; Stop-Job $job; Remove-Job $job -Force }
}

extent analysis

TL;DR

The most likely fix is to identify and clear the uncleared timer or Promise in the CLI initialization phase that keeps the Node.js event loop alive after the command completes.

Guidance

  • Investigate the plugin loading and config loading processes in the CLI initialization phase to identify potential sources of the hang.
  • Use the --cpu-prof flag and analyze the CPU profile to understand where the I/O wait is occurring.
  • Consider using a debugger or logging statements to inspect the event loop and identify any pending timers or Promises that may be causing the hang.
  • Test the provided PowerShell profile wrapper with timeout as a potential workaround to mitigate the issue.

Example

No code snippet is provided as the issue is more related to debugging and identifying the root cause rather than a specific code fix.

Notes

The issue appears to be Windows-specific and may be related to the way Node.js handles event loops and timers on this platform. Further investigation is needed to determine the exact cause and develop a permanent fix.

Recommendation

Apply the provided PowerShell profile wrapper with timeout as a workaround to mitigate the issue, as it allows the command to complete and exit within a reasonable timeframe.

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