Skip to content

fix(cli): retry log follow after a Gateway handshake timeout - #152152

Closed
steipete wants to merge 1 commit into
mainfrom
upd/update-run-abandoned-after-success
Closed

steipete wants to merge 1 commit into
mainfrom
upd/update-run-abandoned-after-success

Conversation

@steipete

@steipete steipete commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes openclaw logs --follow exiting when the Gateway connection fails with Opening handshake has timed out, as reported on Discord.

User Impact

Log following reconnects after this transient handshake timeout and resumes output when the Gateway recovers. Repeated failures still stop after the existing eight retries; authentication and pairing failures keep their existing behavior.

Why This Change Was Made

The follow retry owner recognized typed transport errors and plain Gateway close/request-timeout errors, but omitted the plain timeout message emitted by the WebSocket client. This adds that exact message to the existing retry classification and consolidates duplicate retry-exhaustion test setup.

Evidence

  • The recovery and retry-bound regressions failed before the fix and passed afterward.
  • Four focused logs CLI suites passed: 68 tests covering the CLI, runtime, plain/color output, and port selection.
  • node scripts/check-changed.mjs passed, including production and test typechecks, changed-file lint, line-count ratchets, dead-export scans, and repository guards.
  • Independent committed-branch review at P1: scoped-clean.

Rebased onto main 26c2f997d81b0745d0819ba803c185fde247b72d, which includes the unchanged-base declaration fix from #152028. The authored patch and commit message are unchanged:

1: 1fa5e9c9c3d = 1: 796f3287968 fix(cli): retry log follow after a Gateway handshake timeout

The stable patch IDs also match, so the existing scoped-clean P1 review stands. Exact-head CI for 796f328796877b4b19c4d3f99b4695094761944f is green in run 35404342779, completed successfully with 0 failing and 0 pending CI checks. REST verified the exact head and all 96 check records are completed without failures. No logs-PR CI jobs were rerun.

Production LOC: +8/−12. Tests: +36/−56. This PR contains only the log-follow fix.

@clawsweeper

clawsweeper Bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes size: S maintainer Maintainer-authored PR labels Sep 18, 2026
@steipete
steipete marked this pull request as ready for review September 18, 2026 20:35
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 18, 2026
@clawsweeper

clawsweeper Bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge. Reviewed September 18, 2026, 7:27 PM ET / 23:27 UTC (Revision 3).

ClawSweeper review

What this changes

The PR adds opening-handshake timeout text to CLI log-follow retry classification and consolidates retry-limit and recovery tests.

Merge readiness

⛔ Needs changes before merge - 2 items remain

The prior duplicate-classification finding remains unresolved. Current main already handles this opening timeout through the shared transport adapter; the maintainer-authored, protected PR requires explicit disposition rather than automatic closure.

Priority: P2
Reviewed head: 796f328796877b4b19c4d3f99b4695094761944f

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch is small and has focused validation, but its functional addition duplicates existing recovery and the prior finding remains unresolved.
Proof confidence 🌊 off-meta tidepool Not applicable: The maintainer-authored PR is exempt from the external contributor proof gate. Its tests exercise mocked CLI failures, not the real WebSocket-to-RPC conversion; that distinction supports the functional finding rather than a separate proof blocker.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The maintainer-authored PR is exempt from the external contributor proof gate. Its tests exercise mocked CLI failures, not the real WebSocket-to-RPC conversion; that distinction supports the functional finding rather than a separate proof blocker.
Evidence reviewed 10 items Verified introduced patch: The merge-base-to-head diff changes only log-follow classification and its tests. The new production behavior is the exact opening-timeout string comparison.
Existing normalization on main: The Node WebSocket adapter already assigns ETIMEDOUT to the exact opening-handshake timeout message. This is the authoritative dependency boundary identified by the PR's claimed failure.
Transport-to-CLI causal path: The CLI facade calls callGateway. Its close callback recognizes ETIMEDOUT and creates a GatewayTransportError with kind closed and no numeric close code; the existing CLI classifier accepts that error. The inspected real-TCP handshake regression also asserts ETIMEDOUT.
Findings 1 actionable finding [P1] Remove the duplicate opening-timeout classification
Security None None.

How this fits together

The logs CLI polls the Gateway for log lines and decides whether to retry connection failures or stop. The shared WebSocket adapter normalizes connection errors before the CLI receives them.

flowchart LR
  A[Log follow command] --> B[Gateway RPC client]
  B --> C[WebSocket connection]
  C --> D[Normalize transport failure]
  D --> E{Retry eligible?}
  E -->|Yes, within limit| B
  E -->|No| F[Print error and stop]
  B --> G[Print log lines]
Loading

Before merge

  • Remove the duplicate opening-timeout classification (P1) - The real opening-timeout path already sets ETIMEDOUT in packages/gateway-client/src/client.ts; src/gateway/call.ts then wraps it as a GatewayTransportError accepted by the existing branch above. That normalization is in this PR's parent via fix(gateway): classify opening timeouts and repair lifetime checks #146508. Adding the same dependency-message contract here creates a second classification owner without fixing the reported production path. The new plain-error mocks bypass the normalization and cannot establish its necessity. Remove this condition and the bypass-based cases, or demonstrate a distinct production path requiring them. This remains the prior review's unresolved finding.
  • Complete next step (P2) - Resolve the existing duplicate-classification finding by removing the redundant condition and bypass-based tests, or establishing a distinct production failure that needs them.

Findings

  • [P1] Remove the duplicate opening-timeout classification — src/cli/logs-cli.ts:386-388
Agent review details

Security

None.

PR surface

Source -4, Tests -20. Total -24 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 8 12 -4
Tests 1 36 56 -20
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 44 68 -24

Review metrics

None.

Root-cause cluster

Relationship: superseded
Canonical: #146508
Summary: The merged transport-normalization PR addresses the same opening-timeout mechanism; protected status prevents automatic closure here.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Keep timeout normalization in the WebSocket adapter and let log following consume typed transport errors, retaining only coverage that protects a real production path.

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

No current-main failure is established: source tracing shows the opening timeout becomes an already-retried transport error, while the new tests bypass that conversion. No runtime tests were executed in this read-only review.

Is this the best way to solve the issue?

No. The existing adapter-level normalization is the narrower shared solution; consumer string matching duplicates it without establishing another reachable failure path.

Full review comments:

  • [P1] Remove the duplicate opening-timeout classification — src/cli/logs-cli.ts:386-388
    The real opening-timeout path already sets ETIMEDOUT in packages/gateway-client/src/client.ts; src/gateway/call.ts then wraps it as a GatewayTransportError accepted by the existing branch above. That normalization is in this PR's parent via fix(gateway): classify opening timeouts and repair lifetime checks #146508. Adding the same dependency-message contract here creates a second classification owner without fixing the reported production path. The new plain-error mocks bypass the normalization and cannot establish its necessity. Remove this condition and the bypass-based cases, or demonstrate a distinct production path requiring them. This remains the prior review's unresolved finding.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.98

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 9a57a35aaf3e.

Labels

Label justifications:

  • P2: This is a bounded CLI reliability proposal whose reported transport failure already has shared recovery handling on main.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: The maintainer-authored PR is exempt from the external contributor proof gate. Its tests exercise mocked CLI failures, not the real WebSocket-to-RPC conversion; that distinction supports the functional finding rather than a separate proof blocker.

Evidence

What I checked:

  • Verified introduced patch: The merge-base-to-head diff changes only log-follow classification and its tests. The new production behavior is the exact opening-timeout string comparison. (src/cli/logs-cli.ts:388, 796f32879687)
  • Existing normalization on main: The Node WebSocket adapter already assigns ETIMEDOUT to the exact opening-handshake timeout message. This is the authoritative dependency boundary identified by the PR's claimed failure. (packages/gateway-client/src/client.ts:557, 9a57a35aaf3e)
  • Transport-to-CLI causal path: The CLI facade calls callGateway. Its close callback recognizes ETIMEDOUT and creates a GatewayTransportError with kind closed and no numeric close code; the existing CLI classifier accepts that error. The inspected real-TCP handshake regression also asserts ETIMEDOUT. (src/gateway/call.ts:993, 796f32879687)
  • Current-main retry contract: Main already retries typed timeout errors and closed transport errors without an authentication/pairing close code. The documented follow contract retains eight retries and exponential backoff. (src/cli/logs-cli.ts:379, 9a57a35aaf3e)
  • Merged normalization provenance: GitHub verifies fix(gateway): classify opening timeouts and repair lifetime checks #146508 merged on 2026-09-13T00:13:42Z. Its commit patch adds this normalization, and ancestry checks confirm it is in both the PR parent and fetched main. (packages/gateway-client/src/client.ts:558, 292e1618d9ce)
  • Release boundary: The normalization commit is present on fetched main. The ancestry check against supplied latest release v2026.9.4 returned exit 1; no shipped release containing that commit was established. (292e1618d9ce)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • shashank-poola: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Remove the duplicate classifier and bypass-based cases, or demonstrate the distinct failure through the real transport-to-CLI path.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • 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.

History

Review history (2 earlier review cycles)
  • reviewed 2026-09-18T20:52:19.994Z sha 1fa5e9c :: blocked before merge. :: [P1] Remove the duplicate opening-timeout classification
  • reviewed 2026-09-18T23:12:27.367Z sha 796f328 :: needs changes before merge. :: [P1] Remove the duplicate opening-timeout classification

@steipete
steipete force-pushed the upd/update-run-abandoned-after-success branch from 1fa5e9c to 796f328 Compare September 18, 2026 23:06
@steipete

steipete commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor Author

Superseded by #146508, canonical commit 292e161. ClawSweeper's exact-head P1 is correct: this PR's plain-error tests injected after the normalization boundary and did not establish a remaining production defect.

I verified unmodified main at 3acb23c, without this PR's change, using a session-owned dev Gateway on Linux in an isolated Testbox. The module chain is:

src/cli/logs-cli.ts (fetchGatewayLogs, logs.tail) → src/cli/gateway-rpc.ts → src/cli/gateway-rpc.runtime.ts → src/gateway/call.ts → src/gateway/client.ts → packages/gateway-client/src/client.ts (createSocket) → ws.

The shared adapter assigns ETIMEDOUT to the raw Opening handshake has timed out error. Gateway RPC wraps it as a typed transport error, which log-follow already retries. I found no WebSocket path in the CLI follower that bypasses this adapter.

Boundary proof command, with synthetic authentication, isolated OPENCLAW_STATE_DIR/OPENCLAW_CONFIG_PATH, and free loopback ports:

pnpm openclaw gateway run --allow-unconfigured --bind loopback --port "$gateway_port"
pnpm openclaw logs --follow --json --interval 500 \
  --limit 1000 --max-bytes 1000000 --timeout 60000 \
  --url "ws://127.0.0.1:$proxy_port" --token "$synthetic_token"

A TCP proxy accepted the follower's connection but withheld the HTTP WebSocket upgrade while I stopped and restarted the owned Gateway. The real ws library emitted its opening-handshake timeout at the unchanged 15-second deadline. A passive observer recorded the error's code changing from absent to ETIMEDOUT across the adapter callback; it did not inject or modify errors. Explicit --url ensured the follower used RPC rather than local fallback.

Ancestry (git merge-base --is-ancestor 292e1618d9cedb5ea1c0ad055d8aa907a7876793 <ref>):

Ref Checked SHA Contains canonical fix
v2026.9.4 3a9d69db306cd7f081e06254cb89c4bcc14a7107 No; adapter also lacks normalization
release/2026.9.5 ec9c1a13db8938e5a3eaa51fca2e981cde2395a9 Yes
Tested main 3acb23cdf7d2ad1e89f493e91d725c2e71b5d7f6 Yes
This PR's parent 26c2f997d81b0745d0819ba803c185fde247b72d Yes

The symptom reported on Discord on 2026.9.4 is explained by that version predating the canonical fix. Main and the checked 2026.9.5 release branch already handle it; this PR adds no needed production repair.

Closure is pending a tooling blocker: the maintainer CLI rejected the PR state-change request before dispatch. No merge is needed.

@steipete

Copy link
Copy Markdown
Contributor Author

Closing as superseded by #146508 (292e1618d9), which already classifies the WebSocket opening-handshake timeout as a typed transport error that openclaw logs --follow retries within its existing bound. The boundary proof on unmodified main is in the comment above: withholding the real WebSocket upgrade during an owned Gateway restart produced one timeout, one retry, a successful resume and all 20 records in order; a persistent interruption produced 9 timeouts, exactly 8 retries, then a visible exit 1. v2026.9.4 predates that fix and 2026.9.5 contains it, which explains the version-specific report.

@steipete steipete closed this Sep 18, 2026
@RomneyDa
RomneyDa deleted the upd/update-run-abandoned-after-success branch October 22, 2026 00:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant