-
-
Notifications
You must be signed in to change notification settings - Fork 39.8k
Description
Description
After running any CLI command that completes successfully (e.g. openclaw gateway restart, openclaw daemon status, etc.), the CLI process hangs indefinitely instead of exiting. The user must Ctrl+C to regain the terminal.
$ openclaw gateway restart
21:25:20 [plugins] [token-refresh] Scheduler started (checking every 1min)
21:25:20 [plugins] [unbrowse] Auto-discovery hook active
21:25:20 [plugins] [unbrowse] Plugin registered (16 tools, auto-discover)
🦞 OpenClaw 2026.2.9 (1fad190) — Because texting yourself reminders is so 2024.
Restarted systemd service: openclaw-gateway.service
^C^C^C
Root Cause
Two issues combine to cause this:
-
No explicit process exit in
runCli(): Afterprogram.parseAsync()resolves insrc/cli/run-main.ts, the function just returns. Commander.js does not force-exit the process. -
Eager side-effect imports keep the event loop alive:
src/cli/daemon-cli/register.tscallsvoid createDefaultDeps()at registration time, which eagerly imports all messaging-provider modules (WhatsApp, Telegram, Discord, Slack, Signal, iMessage). These modules create persistent connections or timers that prevent Node.js from exiting naturally.
The failure path (defaultRuntime.exit(1)) works fine — it's only the success paths that hang, since they just return without exiting.
Affected Commands
This is not limited to gateway restart. Any CLI command whose success path doesn't explicitly call process.exit() / defaultRuntime.exit() will hang when side-effect imports keep the event loop alive.
Related: #7662
Expected Behavior
The CLI should exit cleanly (exit code 0) once a command completes successfully.
Environment
- OS: AlmaLinux 10.1 (aarch64)
- Kernel: Linux 6.12.0-124.31.1.el10_1.aarch64
- Node.js: v22.22.0
- OpenClaw: 2026.2.9 (1fad190)