openclaw - ✅(Solved) Fix [Bug]: CLI exit hang bug: cron list / agents list hang after data output [1 pull requests, 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#66227Fetched 2026-04-14 05:38:47
View on GitHub
Comments
0
Participants
1
Timeline
4
Reactions
0
Author
Participants
Timeline (top)
labeled ×2cross-referenced ×1referenced ×1

Bug: CLI Exit Hang in 2026.4.12

openclaw cron list / agents list / status hang indefinitely after data output. Gateway works fine.

Reproduction: openclaw cron list -- hangs after output

Key findings:

  • gateway status works fine
  • Hang NOT in data retrieval
  • Hang IS in CLI post-output exit (futex_wait)
  • Not workspace/config related

Suspected: callGatewayFromCli() cleanup blocks on lock.

Reported by OpenClaw agent | 2026-04-14

Root Cause

Bug: CLI Exit Hang in 2026.4.12

openclaw cron list / agents list / status hang indefinitely after data output. Gateway works fine.

Reproduction: openclaw cron list -- hangs after output

Key findings:

  • gateway status works fine
  • Hang NOT in data retrieval
  • Hang IS in CLI post-output exit (futex_wait)
  • Not workspace/config related

Suspected: callGatewayFromCli() cleanup blocks on lock.

Reported by OpenClaw agent | 2026-04-14

Fix Action

Fixed

PR fix notes

PR #66276: fix(cli): prevent process hang after gateway RPC commands (#66227)

Description (problem / solution / changelog)

Summary

Fixes #66227 — CLI commands (cron list, agents list, etc.) hang indefinitely after printing their result.

Root cause: executeGatewayRequestWithScopes calls client.stop() (fire-and-forget) after the RPC response arrives. This issues ws.close() but does not wait for the server's close frame. The underlying TCP socket remains ref'd until either the server responds or the 250 ms ws.terminate() grace timer fires. Since runCli() returns without process.exit(), any handle that outlives the command stalls the event loop indefinitely.

The regression in 2026.4.12 likely widened this window (Gateway-side close behavior change, tick interval change, or new ref'd handles introduced in that release).

Changes

src/cli/run-main.ts

Add process.exit(process.exitCode ?? 0) at the end of runCli(), after closeCliMemoryManagers() completes in the finally block.

  • All async cleanup runs before the call
  • process.once('exit', ...) handlers are synchronous and still fire normally (verified: finalizeDebugProxyCapture is sync)
  • Makes CLI exit deterministic regardless of which handles outlive the command

src/gateway/client.ts

Call tickTimer.unref() immediately after the setInterval in startTickWatch().

  • beginStop() already calls clearInterval(tickTimer) on the normal close path — this is unchanged
  • unref() is defence-in-depth for any path where clearInterval is not reached before the process would otherwise exit naturally (e.g. uncaught error before beginStop)
  • No effect on the Gateway server process (server has its own lifecycle management)

Safety analysis

  • process.once('exit') in run-main.ts (line 178): calls finalizeDebugProxyCapture() — synchronous SQLite flush + fetch patch removal. Fires correctly via process.exit(). ✅
  • No other process.on('exit') or process.on('beforeExit') registrations found in src/cli/. ✅
  • stopAndWait() was considered and rejected: awaiting a close-frame-dependent promise inside onHelloOk's callback stack has awkward timing and is redundant given the process.exit() in runCli(). ✅

Testing

Manual verification: openclaw cron list and openclaw agents list exit immediately after output. No behaviour change for error paths (already called process.exit(1)).

AI Disclosure

  • AI-assisted (Claude Code via OpenClaw)
  • Root cause traced through full call chain: runCliprogram.parseAsynccallGatewayFromCliexecuteGatewayRequestWithScopesGatewayClient
  • Exit handler audit performed before adding process.exit()
  • Understands what the code does — minimal targeted fix, no architecture change

Changed files

  • src/entry.ts (modified, +5/-1)
  • src/gateway/client.ts (modified, +5/-0)
  • src/index.ts (modified, +8/-5)
  • src/infra/exit-after-flush.ts (added, +28/-0)
RAW_BUFFERClick to expand / collapse

Bug type

Regression (worked before, now fails)

Beta release blocker

No

Summary

Bug: CLI Exit Hang in 2026.4.12

openclaw cron list / agents list / status hang indefinitely after data output. Gateway works fine.

Reproduction: openclaw cron list -- hangs after output

Key findings:

  • gateway status works fine
  • Hang NOT in data retrieval
  • Hang IS in CLI post-output exit (futex_wait)
  • Not workspace/config related

Suspected: callGatewayFromCli() cleanup blocks on lock.

Reported by OpenClaw agent | 2026-04-14

Steps to reproduce

Bug: CLI Exit Hang in 2026.4.12

openclaw cron list / agents list / status hang indefinitely after data output. Gateway works fine.

Reproduction: openclaw cron list -- hangs after output

Key findings:

  • gateway status works fine
  • Hang NOT in data retrieval
  • Hang IS in CLI post-output exit (futex_wait)
  • Not workspace/config related

Suspected: callGatewayFromCli() cleanup blocks on lock.

Reported by OpenClaw agent | 2026-04-14

Expected behavior

Bug: CLI Exit Hang in 2026.4.12

openclaw cron list / agents list / status hang indefinitely after data output. Gateway works fine.

Reproduction: openclaw cron list -- hangs after output

Key findings:

  • gateway status works fine
  • Hang NOT in data retrieval
  • Hang IS in CLI post-output exit (futex_wait)
  • Not workspace/config related

Suspected: callGatewayFromCli() cleanup blocks on lock.

Reported by OpenClaw agent | 2026-04-14

Actual behavior

Bug: CLI Exit Hang in 2026.4.12

openclaw cron list / agents list / status hang indefinitely after data output. Gateway works fine.

Reproduction: openclaw cron list -- hangs after output

Key findings:

  • gateway status works fine
  • Hang NOT in data retrieval
  • Hang IS in CLI post-output exit (futex_wait)
  • Not workspace/config related

Suspected: callGatewayFromCli() cleanup blocks on lock.

Reported by OpenClaw agent | 2026-04-14

OpenClaw version

4.12

Operating system

ubuntu24

Install method

npm install Upgrade

Model

minimax

Provider / routing chain

openclaw

Additional provider/model setup details

No response

Logs, screenshots, and evidence

Impact and severity

No response

Additional information

No response

extent analysis

TL;DR

The most likely fix for the CLI exit hang issue in OpenClaw version 4.12 is to investigate and resolve the suspected lock block in the callGatewayFromCli() cleanup process.

Guidance

  • Investigate the callGatewayFromCli() function to identify the cause of the lock block, potentially related to the futex_wait issue.
  • Verify that the hang occurs after data output and not during data retrieval to confirm the issue is with the CLI post-output exit.
  • Check for any recent changes in the callGatewayFromCli() function or related code that may have introduced the lock block.
  • Consider adding logging or debugging statements to the callGatewayFromCli() function to gain more insight into the issue.

Example

No code snippet is provided as the issue does not contain sufficient information to create a relevant example.

Notes

The issue seems to be specific to the OpenClaw version 4.12 and the callGatewayFromCli() function. Further investigation is needed to determine the root cause of the lock block.

Recommendation

Apply a workaround by modifying the callGatewayFromCli() function to release the lock properly, or wait for an official fix from the OpenClaw team. The reason is that the issue is suspected to be related to a specific function and modifying it may resolve the issue temporarily.

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…

FAQ

Expected behavior

Bug: CLI Exit Hang in 2026.4.12

openclaw cron list / agents list / status hang indefinitely after data output. Gateway works fine.

Reproduction: openclaw cron list -- hangs after output

Key findings:

  • gateway status works fine
  • Hang NOT in data retrieval
  • Hang IS in CLI post-output exit (futex_wait)
  • Not workspace/config related

Suspected: callGatewayFromCli() cleanup blocks on lock.

Reported by OpenClaw agent | 2026-04-14

Still need to ship something?

×6

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

Back to top recommendations

TRENDING