openclaw - 💡(How to fix) Fix CLI: and non-direct invocations can fail with 1006 while direct remains the only stable path [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#60651Fetched 2026-04-08 02:48:44
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0

There are two overlapping bugs behind the same 1006 abnormal closure symptom:

  1. cron namespace regression
  2. structural CLI invocation / bootstrap failure outside the most direct launch path

The scheduler and gateway remain healthy. The failure is in the CLI path, not in cron execution itself.

Error Message

Error: gateway closed (1006 abnormal closure (no close frame)): no close reason Gateway target: ws://127.0.0.1:18789 Source: local loopback Config: /Users/danilolima/.openclaw/openclaw.json Bind: loopback

Root Cause

Most Likely Root Cause

Code Example

/opt/homebrew/bin/openclaw gateway call cron.status --json

---

/opt/homebrew/bin/openclaw cron status --json

---

~/.openclaw/bin/openclaw-secure gateway call cron.status --json
/bin/zsh -lc '/opt/homebrew/bin/openclaw gateway call cron.status --json'
OPENCLAW_NO_RESPAWN=1 /opt/homebrew/bin/openclaw gateway call cron.status --json

---

Error: gateway closed (1006 abnormal closure (no close frame)): no close reason
Gateway target: ws://127.0.0.1:18789
Source: local loopback
Config: /Users/danilolima/.openclaw/openclaw.json
Bind: loopback

---

set -a
source .env
set +a
OPENCLAW_NO_RESPAWN=1 /opt/homebrew/bin/openclaw gateway call cron.status --json

---

/opt/homebrew/bin/openclaw gateway call cron.status --json

---

/opt/homebrew/bin/openclaw cron status --json

---

/bin/zsh -lc '/opt/homebrew/bin/openclaw gateway call cron.status --json'

---

OPENCLAW_NO_RESPAWN=1 /opt/homebrew/bin/openclaw gateway call cron.status --json
RAW_BUFFERClick to expand / collapse

Issue Draft - OpenClaw CLI invocation 1006

Title

openclaw cron ... and non-direct CLI invocations can fail with 1006; direct gateway call via /opt/homebrew/bin/openclaw is the only stable path observed

Severity

S2

Summary

There are two overlapping bugs behind the same 1006 abnormal closure symptom:

  1. cron namespace regression
  2. structural CLI invocation / bootstrap failure outside the most direct launch path

The scheduler and gateway remain healthy. The failure is in the CLI path, not in cron execution itself.

User Impact

  • openclaw cron status|list|run is unreliable or broken
  • wrappers and subprocess-based automation can fail even when the gateway is healthy
  • operators may misdiagnose the incident as "cron dead" when cron.* RPC still works

Known Good Path

/opt/homebrew/bin/openclaw gateway call cron.status --json

Broken Paths

Direct cron regression:

/opt/homebrew/bin/openclaw cron status --json

Non-direct invocation failures:

~/.openclaw/bin/openclaw-secure gateway call cron.status --json
/bin/zsh -lc '/opt/homebrew/bin/openclaw gateway call cron.status --json'
OPENCLAW_NO_RESPAWN=1 /opt/homebrew/bin/openclaw gateway call cron.status --json

Expected Result

All supported CLI invocation paths should either:

  • successfully complete the same RPC call, or
  • fail with a clear credential/config error

They should not collapse into 1006 abnormal closure for healthy local gateway operation.

Actual Result

Observed failure:

Error: gateway closed (1006 abnormal closure (no close frame)): no close reason
Gateway target: ws://127.0.0.1:18789
Source: local loopback
Config: /Users/danilolima/.openclaw/openclaw.json
Bind: loopback

Important Diagnosis

Bug A - cron regression

cron status fails even when the equivalent RPC succeeds via gateway call.

That means cron still has its own regression.

Bug B1 - SecretRef / credential resolution can surface as 1006

Part of the failure class is credential resolution.

gateway.auth.token is configured via env/SecretRef, and some CLI paths reach:

  • missing env var "OPENCLAW_GATEWAY_TOKEN"
  • GatewaySecretRefUnavailableError

Relevant code:

This shows that some 1006 errors are secondary to auth materialization failure before the WebSocket request completes.

Bug B2 - Bootstrap / handshake failure remains even with token present

Even when .env is explicitly loaded and OPENCLAW_GATEWAY_TOKEN is present, the following still fails:

set -a
source .env
set +a
OPENCLAW_NO_RESPAWN=1 /opt/homebrew/bin/openclaw gateway call cron.status --json

So credential absence is not the full explanation.

The self-respawn in entry.js is part of the only consistently healthy path, but respawn alone is not sufficient to fix all wrappers and indirect launches.

Minimal Reproduction Set

Control:

/opt/homebrew/bin/openclaw gateway call cron.status --json

Repro A:

/opt/homebrew/bin/openclaw cron status --json

Repro B1 or B2, depending on credential state:

/bin/zsh -lc '/opt/homebrew/bin/openclaw gateway call cron.status --json'

Repro B2 specifically:

OPENCLAW_NO_RESPAWN=1 /opt/homebrew/bin/openclaw gateway call cron.status --json

Most Likely Root Cause

This currently looks like a layered failure:

  • cron-cli path remains regressed
  • some non-direct invocation paths lose or fail SecretRef materialization
  • independently, the non-respawned client path can still fail during bootstrap or handshake before hello completes

Suggested Repair Order

  1. Treat cron regression and structural invocation bug as separate tickets if needed
  2. Instrument final auth selection in the child process of gateway call
  3. Compare healthy respawned process vs OPENCLAW_NO_RESPAWN=1
  4. Inspect GatewayClient connect/hello/device-auth path for the remaining non-auth 1006

Acceptance Criteria

  • /opt/homebrew/bin/openclaw cron status --json succeeds when gateway call cron.status succeeds
  • indirect shells and wrappers do not fail with 1006 when the local gateway is healthy
  • missing SecretRef/token cases surface a direct auth/config error, not a misleading WebSocket close
  • OPENCLAW_NO_RESPAWN=1 /opt/homebrew/bin/openclaw gateway call cron.status --json either works or fails with an explicit, actionable reason

Supporting Notes

Detailed local analysis and evidence:

extent analysis

TL;DR

The most likely fix involves addressing the cron regression and the structural invocation bug, including instrumenting final auth selection and comparing healthy respawned processes.

Guidance

  • Investigate and separate the cron regression and structural invocation bug into distinct issues for clearer resolution.
  • Instrument the final auth selection in the child process of gateway call to better understand the authentication flow.
  • Compare the behavior of healthy respawned processes versus those run with OPENCLAW_NO_RESPAWN=1 to identify differences in their execution.
  • Inspect the GatewayClient connect, hello, and device-auth path for non-auth related 1006 errors to ensure all potential failure points are addressed.

Example

No specific code snippet is provided due to the complexity and variability of the issue, but the process of instrumenting auth selection could involve logging or debugging statements in the credentials-DyjdApQe.js file.

Notes

The solution requires a layered approach, addressing both the cron regression and the issues with non-direct invocation paths, including credential resolution and bootstrap/handshake failures. The provided steps are aimed at diagnosing and potentially resolving these issues but may need adaptation based on specific implementation details not fully captured in the issue description.

Recommendation

Apply a workaround by using the direct gateway call method until the underlying issues are fully resolved, as it is the only consistently stable path observed. This approach allows for continued functionality while the root causes are investigated and fixed.

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

openclaw - 💡(How to fix) Fix CLI: and non-direct invocations can fail with 1006 while direct remains the only stable path [1 participants]