Skip to content

fix(gateway): show last error when status probe fails - #95902

Merged
vincentkoc merged 2 commits into
openclaw:mainfrom
wAngByg:fix-gateway-status-rpc-last-error
Jul 7, 2026
Merged

vincentkoc merged 2 commits into
openclaw:mainfrom
wAngByg:fix-gateway-status-rpc-last-error

Conversation

@wAngByg

@wAngByg wAngByg commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

openclaw gateway status --deep can currently show a running gateway service and a busy gateway port while the RPC probe only reports a generic close, for example gateway closed (1000):. In that state the actionable server-side error is already present in the gateway logs, but the status command does not surface it unless the port is not listening.

A real field case had the service active, port 2345 owned by the gateway process, and Feishu running, while openclaw gateway status --deep --json reported rpc.ok=false with only gateway closed (1000):. The gateway journal showed the actual cause: parse/handle error: Error: ENOSPC: no space left on device, write.

Why This Change Was Made

This keeps the existing status diagnostic model and applies it to the missing case:

  • read the latest gateway error when the managed service is running but the RPC probe fails, even if the port is listening
  • print that Last gateway error next to the failed connectivity/read probe
  • prioritize ENOSPC / no space left on device log lines when selecting the most useful recent gateway error

This does not change gateway auth, RPC behavior, service lifecycle, or log redaction. It only makes existing diagnostics more actionable.

User Impact

Users who run openclaw gateway status --deep against a listening but internally failing gateway will see the likely root cause immediately instead of needing to know which service logs or journal entries to inspect. Disk-full failures become visible as a direct status hint rather than a misleading generic WebSocket close.

Evidence

Field evidence from the affected host:

  • df -h /: root filesystem was 100% full
  • openclaw gateway status --deep --json: service runtime was running, port status was busy, listener PID owned /usr/lib/node_modules/openclaw/dist/index.js gateway --port 2345, but rpc.ok=false and rpc.error="gateway closed (1000): "
  • gateway journal contained parse/handle error: Error: ENOSPC: no space left on device, write

Local validation:

  • corepack pnpm test src/daemon/diagnostics.test.ts
  • corepack pnpm test src/cli/daemon-cli/status.gather.test.ts
  • corepack pnpm test src/cli/daemon-cli/status.print.test.ts
  • corepack pnpm test:changed
  • corepack pnpm exec oxfmt --check --threads=1 src/daemon/diagnostics.ts src/daemon/diagnostics.test.ts src/cli/daemon-cli/status.gather.ts src/cli/daemon-cli/status.gather.test.ts src/cli/daemon-cli/status.print.ts src/cli/daemon-cli/status.print.test.ts
  • OPENCLAW_CHECK_CHANGED_REMOTE_CHILD=1 CI=1 corepack pnpm check:changed

AI-assisted: investigated and implemented with Codex; changes and evidence were manually reviewed before submission.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime cli CLI command changes size: S labels Jun 23, 2026
@wAngByg
wAngByg force-pushed the fix-gateway-status-rpc-last-error branch from da09d6f to e3bf279 Compare June 23, 2026 02:09
@clawsweeper

clawsweeper Bot commented Jun 23, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed June 29, 2026, 11:23 PM ET / 03:23 UTC.

Summary
The PR widens gateway status gathering to read the last gateway log error when an RPC probe fails, prints that error beside failed probe output, and adds ENOSPC log matching plus focused tests.

PR surface: Source +7, Tests +117. Total +124 across 6 files.

Reproducibility: yes. source-level: current main only gathers lastError for a running service when the port is not busy, so a busy listener with rpc.ok=false cannot show the log error. I did not run a live gateway in this read-only review.

Review metrics: none identified.

Merge readiness
Overall: 🧂 unranked krab
Proof: 🧂 unranked krab
Patch quality: 🦪 silver shellfish
Result: blocked until real behavior proof is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P1] Add redacted after-fix terminal output or logs showing the changed openclaw gateway status --deep behavior in a real or log-seeded setup.
  • Narrow lastError collection to local managed probe failures and prevent duplicate Last gateway error output.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The PR body has pre-fix field evidence and test commands, but no after-fix real gateway status output; the contributor should add redacted terminal output, logs, or a terminal screenshot and update the PR body.

Risk before merge

  • [P1] The PR can attach a stale local Gateway log error to an explicit or remote probe failure, which would mislead users debugging auth, scope, or remote-target failures.
  • [P1] The PR can print the same Last gateway error twice when the service is running but the port is not listening, because the old not-listening renderer still runs.
  • [P1] External real behavior proof is still missing; tests and pre-fix field evidence do not show the after-fix CLI output.

Maintainer options:

  1. Decide the mitigation before merge
    Scope the log read/rendering to local managed RPC failures where the listener is relevant, keep Last gateway error rendered once, and add redacted after-fix terminal output for the real openclaw gateway status --deep path.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • [P1] Needs contributor proof plus a small author-side scope/render fix; do not queue repair while the external real behavior proof gate is still unsatisfied.

Security
Cleared: No concrete security or supply-chain issue found; the diff only changes local CLI diagnostics and tests.

Review findings

  • [P2] Keep local log errors scoped to local probes — src/cli/daemon-cli/status.gather.ts:711
  • [P3] Avoid printing the last gateway error twice — src/cli/daemon-cli/status.print.ts:277-279
Review details

Best possible solution:

Scope the log read/rendering to local managed RPC failures where the listener is relevant, keep Last gateway error rendered once, and add redacted after-fix terminal output for the real openclaw gateway status --deep path.

Do we have a high-confidence way to reproduce the issue?

Yes, source-level: current main only gathers lastError for a running service when the port is not busy, so a busy listener with rpc.ok=false cannot show the log error. I did not run a live gateway in this read-only review.

Is this the best way to solve the issue?

No. The layer is plausible, but the implementation should be narrowed to local managed probe failures and avoid duplicate rendering before it is the best fix.

Full review comments:

  • [P2] Keep local log errors scoped to local probes — src/cli/daemon-cli/status.gather.ts:711
    The widened condition now reads the local managed service logs whenever rpc.ok === false. For --url or remote-mode probes, that failure can be for a different gateway target while the local service is merely running, so the output can attach a stale local Last gateway error to an auth/scope/remote failure. Gate this to local managed probe failures, consistent with the existing probeUrlOverride checks around other local-only diagnostics.
    Confidence: 0.86
  • [P3] Avoid printing the last gateway error twice — src/cli/daemon-cli/status.print.ts:277-279
    In the existing service-running/port-not-listening case, lastError is already set and the existing later branch prints Last gateway error: with log paths. The new RPC-failure print runs first for the same failed probe, so that path will emit the same last error twice. Guard the new print to the busy-listener RPC-failure case or move the rendering to a single shared location.
    Confidence: 0.88

Overall correctness: patch is incorrect
Overall confidence: 0.86

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 54b09580f61b.

Label changes

Label justifications:

  • P2: The PR targets a useful gateway CLI diagnostic bug with limited blast radius, but the current patch needs focused fixes before merge.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦪 silver shellfish.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body has pre-fix field evidence and test commands, but no after-fix real gateway status output; the contributor should add redacted terminal output, logs, or a terminal screenshot and update the PR body.
Evidence reviewed

PR surface:

Source +7, Tests +117. Total +124 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 3 11 4 +7
Tests 3 125 8 +117
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 136 12 +124

What I checked:

  • Repository policy read: Read the full root AGENTS.md and applied the OpenClaw PR review, proof, gateway diagnostics, and no-mutation guidance; no scoped AGENTS.md exists for src/cli/daemon-cli or src/daemon. (AGENTS.md:1, 54b09580f61b)
  • Current main gap: Current main only reads lastError when the service is running and the daemon port is not busy, so a busy listener with rpc.ok=false cannot surface the gateway log error. (src/cli/daemon-cli/status.gather.ts:707, 54b09580f61b)
  • PR widens log read for every RPC failure: The PR changes the gather condition to read local gateway logs whenever rpc.ok is false while the service is running. (src/cli/daemon-cli/status.gather.ts:711, e3bf27930c4c)
  • Existing explicit URL boundary: Current status gathering treats probeUrlOverride as a local-diagnostics boundary for TLS runtime and plugin drift, which makes unguarded local log reads on explicit/remote probe failures risky. (src/cli/daemon-cli/status.gather.ts:430, 54b09580f61b)
  • Existing last-error renderer: Current main already prints Last gateway error in the service-running, port-not-listening branch. (src/cli/daemon-cli/status.print.ts:429, 54b09580f61b)
  • PR adds another last-error renderer: The PR also prints status.lastError in the failed RPC block, so the existing not-listening path can print the same log line twice. (src/cli/daemon-cli/status.print.ts:277, e3bf27930c4c)

Likely related people:

  • sallyom: Authored merged gateway status diagnostic work that touched status.gather.ts, status.print.ts, and probe.ts, including live proof for status output behavior. (role: adjacent status diagnostics contributor; confidence: medium; commits: b763793b60d4, cbc69d9a96d7; files: src/cli/daemon-cli/status.gather.ts, src/cli/daemon-cli/status.print.ts, src/cli/daemon-cli/probe.ts)
  • Alix-007: Authored the merged PR that changed readLastGatewayErrorLine stderr/stdout precedence in the same helper this PR extends. (role: adjacent diagnostics helper contributor; confidence: medium; commits: 357000c80525, f6a3ac7e58ae; files: src/daemon/diagnostics.ts, src/daemon/diagnostics.test.ts)
  • vincentkoc: Merged the adjacent diagnostics helper fix and the unsupported service status PR that touched daemon status gathering tests. (role: recent adjacent merger and reviewer signal; confidence: medium; commits: f6a3ac7e58ae, 6a2ec6286535; files: src/daemon/diagnostics.ts, src/cli/daemon-cli/status.gather.test.ts, src/commands/status.daemon.test.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. labels Jun 23, 2026
@vincentkoc
vincentkoc force-pushed the fix-gateway-status-rpc-last-error branch from e3bf279 to b89c2cd Compare July 7, 2026 05:10
@vincentkoc vincentkoc self-assigned this Jul 7, 2026
@vincentkoc
vincentkoc merged commit 70c2e83 into openclaw:main Jul 7, 2026
110 of 112 checks passed
@vincentkoc

Copy link
Copy Markdown
Member

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 7, 2026
* fix(gateway): show last error when status probe fails

* fix(gateway): scope status log diagnostics

---------

Co-authored-by: wAngByg <[email protected]>
Co-authored-by: Vincent Koc <[email protected]>
sheyanmin pushed a commit to sheyanmin/openclaw that referenced this pull request Jul 8, 2026
* fix(gateway): show last error when status probe fails

* fix(gateway): scope status log diagnostics

---------

Co-authored-by: wAngByg <[email protected]>
Co-authored-by: Vincent Koc <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: M status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants