Skip to content

fix(reef): add timeout and bounded JSON reads to relay transport - #108333

Merged
steipete merged 3 commits into
openclaw:mainfrom
cxbAsDev:fix/reef-relay-transport-timeout
Jul 18, 2026
Merged

steipete merged 3 commits into
openclaw:mainfrom
cxbAsDev:fix/reef-relay-transport-timeout

Conversation

@cxbAsDev

@cxbAsDev cxbAsDev commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

The Reef relay transport client (extensions/reef/src/transport.ts) had no request deadline. A relay that stalls before headers or during a response body can pin ReefInboxConnection.drain() and stop recovery.

Why This Change Was Made

Bounded JSON reads already landed on main via #106456. This PR adds the missing 15 s request deadline with buildTimeoutAbortSignal, composes it with the inbox caller signal, and keeps it active through response-body consumption. Ordinary HTTP failures remain typed ReefRelayErrors; a stalled success or error body preserves the TimeoutError.

User Impact

  • Prevents silent channel death when the Reef relay becomes unresponsive before headers or during a response body.
  • No behavior change for healthy relays; a stall surfaces as a TimeoutError at the 15 s deadline and triggers the existing reconnect path.

Evidence

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime channel: reef Channel integration: reef size: S labels Jul 15, 2026
@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 Jul 16, 2026
@clawsweeper

clawsweeper Bot commented Jul 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 18, 2026, 7:52 AM ET / 11:52 UTC.

Summary
The branch adds a composed 15-second timeout around Reef relay HTTP requests and a loopback-server test suite for stalls before headers and after headers during JSON reads.

PR surface: Source +19, Tests +80. Total +99 across 2 files.

Reproducibility: yes. in source: extensions/reef/src/transport.timeout.test.ts provides concrete loopback relay paths for stalls before headers and after headers. The review did not execute those tests because the read-only terminal sandbox could not start commands.

Review metrics: 1 noteworthy metric.

  • New relay deadline: 1 added 15-second request deadline. This intentionally converts indefinitely stalled relay requests into a recovery-triggering failure state.

Merge readiness
Overall: 🦐 gold shrimp
Proof: 🦐 gold shrimp
Patch quality: 🐚 platinum hermit
Result: blocked until stronger 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:

  • Post redacted final-head terminal or live output for the post-header stalled-body timeout path.
  • Update the PR body with that evidence so a fresh ClawSweeper review can verify the exact head; if it does not trigger, ask a maintainer to comment @clawsweeper re-review.

Proof guidance:

  • [P1] Needs stronger real behavior proof before merge: The contributor supplied useful live loopback evidence for a pre-header timeout, bounded JSON rejection, and recovery, but the current evidence does not show final-head real behavior for a response that sends headers and then stalls during body consumption. Add redacted terminal/live output for that path; tests and CI remain supplemental. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Risk before merge

  • [P1] A healthy but slow relay response that exceeds 15 seconds will now fail into recovery; before merge, maintainers need final-head real proof that both pre-header and post-header stalls surface as TimeoutError and do not leave the inbox drain pinned.

Maintainer options:

  1. Add final-head stalled-body proof (recommended)
    Post redacted output from the current head showing a relay that returns headers, stalls during JSON body consumption, then rejects as TimeoutError and allows the reconnect path to proceed.
  2. Accept the observability gap
    Maintainers may merge based on source coverage and CI while explicitly accepting that the required post-header live behavior has not been demonstrated.

Next step before merge

  • [P1] The remaining merge blocker is contributor-supplied real behavior evidence, not a narrow repair that ClawSweeper can credibly create on the contributor's behalf.

Security
Cleared: The diff uses an existing OpenClaw timeout helper and local loopback test server; it adds no dependency, credential, workflow, permission, or supply-chain surface.

Review details

Best possible solution:

Keep the shared bounded JSON reader and land the composed timeout after the contributor posts redacted final-head terminal or live output that exercises a response which sends headers and then stops producing body bytes.

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

Yes in source: extensions/reef/src/transport.timeout.test.ts provides concrete loopback relay paths for stalls before headers and after headers. The review did not execute those tests because the read-only terminal sandbox could not start commands.

Is this the best way to solve the issue?

Yes for the code shape: composing the existing timeout helper with the caller signal at the transport request boundary preserves the shared bounded JSON-reader path. The remaining requirement is evidence that the post-header body-stall path works on the final head in a real run.

AGENTS.md: found and applied where relevant.

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

Label changes

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.

Label justifications:

  • P2: The PR addresses a bounded channel-recovery reliability failure without evidence of an active broad outage.
  • merge-risk: 🚨 availability: The new fixed deadline can make previously long-running relay requests fail and enter reconnect handling.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The contributor supplied useful live loopback evidence for a pre-header timeout, bounded JSON rejection, and recovery, but the current evidence does not show final-head real behavior for a response that sends headers and then stalls during body consumption. Add redacted terminal/live output for that path; tests and CI remain supplemental. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed

PR surface:

Source +19, Tests +80. Total +99 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 44 25 +19
Tests 1 80 0 +80
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 124 25 +99

What I checked:

Likely related people:

  • steipete: Authored the maintainer fixup that introduced the relay request deadline now proposed for merge. (role: recent area contributor; confidence: high; commits: b94da60a30be, dd9820058449; files: extensions/reef/src/transport.ts, extensions/reef/src/transport.timeout.test.ts)
  • Pick-cat: Authored the merged bounded relay JSON-read change that this timeout path deliberately reuses rather than duplicating. (role: adjacent owner; confidence: medium; commits: a0755802a7f1, 9026b9f4ac82; files: extensions/reef/src/transport.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.
Review history (15 earlier review cycles; latest 8 shown)
  • reviewed 2026-07-17T08:20:44.841Z sha 1ec8c486b66a83ad599b6d2386ad6d9d80742349 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-17T14:12:50.051Z sha f6b3e1756771ae62776aae95a6761b636e2149f6 :: needs changes before merge. :: [P1] Restore the daemon runtime probe timeout
  • reviewed 2026-07-17T14:51:11.082Z sha 33b2d582d59ce97dfbe9b255f1a75a74f34074a3 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-17T15:02:10.546Z sha 33b2d582d59ce97dfbe9b255f1a75a74f34074a3 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-18T07:28:31.966Z sha bb059df271384cc7b16dd5bc8abf88ea87242bdb :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-18T07:58:25.879Z sha bb059df271384cc7b16dd5bc8abf88ea87242bdb :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-18T08:17:05.835Z sha b94da60 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-18T11:23:54.409Z sha 5f0b8dc :: needs real behavior proof before merge. :: none

@cxbAsDev
cxbAsDev force-pushed the fix/reef-relay-transport-timeout branch from a215c6e to 5d2038c Compare July 16, 2026 08:53
@openclaw-barnacle openclaw-barnacle Bot added size: XS and removed gateway Gateway runtime size: S labels Jul 16, 2026
@cxbAsDev

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Both review asks are addressed on the new head 5d2038ccba1.

Branch is now Reef-only. The unrelated daemon commit (d50465f, src/daemon/runtime-paths.ts) is dropped; the branch is current main (f460c2871a0) plus a single Reef transport commit. The daemon remediation already ships separately as #107990, so no work was lost. Note: bounded relay JSON reads landed on main in the meantime via #106456 (16 MiB success / 64 KiB error caps), so this PR's delta reduced to the missing piece — the 15 s request timeout (fetchWithTimeout around the relay fetch, plus a stalled-relay regression test).

Exact-head controlled-relay proof. Real loopback HTTP+WebSocket relay (no fetch mocks; real ReefTransportClient / ReefInboxConnection over real sockets, throwaway test keys, 127.0.0.1 only — nothing to redact). Head: 5d2038ccba1.

[+     8ms] controlled relay listening at http://127.0.0.1:35409 (loopback only)
[+   236ms] PASS phase1 healthy pull: cursor=42 entries=0
[fetch-timeout] fetch timeout after 15000ms (elapsed 15001ms) operation=fetchWithTimeout url=http://127.0.0.1:35409/v1/mail
[+ 15317ms] PASS phase2 stall abort: name=TimeoutError elapsed=15080ms (deadline 15000ms)
[+ 15520ms] PASS phase3 oversized rejected: reef.relay: JSON response exceeds 16777216 bytes
[+ 17024ms] relay switches fail500 -> healthy-entry (simulating relay recovery)
[+ 17296ms] inbox onEntries seq=1 peer=bob id=msg-1
[+ 17312ms] inbox state -> connected
[+ 17464ms] inbox onEntries seq=2 peer=bob id=msg-2
[+ 17487ms] inbox state -> disconnected
[+ 17488ms] PASS phase4 reconnect recovery: states=connected,disconnected drainedSeq1=true liveSeq2=true
[+ 17488ms] PROOF OK: all 4 phases passed

This covers the four requested behaviors: stalled pre-header request aborts at the 15 s deadline (surfaces as TimeoutError from undici), oversized body is rejected instead of buffered, healthy requests pass through, and the reconnect/backoff loop keeps polling through relay 500s and recovers (drain + live WS push) once the relay is healthy again.

Focused tests on the same head: node scripts/run-vitest.mjs extensions/reef/src/transport.test.ts --run — 10/10 passed.

@clawsweeper

clawsweeper Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Command router queued. I will update this comment with the next step.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. and removed 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. labels Jul 16, 2026
@cxbAsDev

Copy link
Copy Markdown
Contributor Author

Rebased onto current upstream/main (resolved a trivial duplicate-entry conflict in src/tasks/task-boundaries.test.ts) and refreshed the merge candidate. This should clear the stale check-test-types errors caused by the old base.

@cxbAsDev
cxbAsDev force-pushed the fix/reef-relay-transport-timeout branch from 9dc07e5 to ae0c6ae Compare July 17, 2026 01:47
@cxbAsDev

Copy link
Copy Markdown
Contributor Author

Rebased onto current upstream/main and resolved the merge conflicts in extensions/reef/src/transport.ts and extensions/reef/src/transport.test.ts (kept both the new WebSocket bounds from main and the relay request-timeout changes from this branch). Local focused test passes:

node scripts/run-vitest.mjs extensions/reef/src/transport.test.ts --run

This should clear the stale check-test-types errors caused by the old base.

@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. labels Jul 17, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the gateway Gateway runtime label Jul 17, 2026
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed 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 Jul 17, 2026
@cxbAsDev

Copy link
Copy Markdown
Contributor Author

PR Ready for Maintainer Review

Branch has been cleaned up — only Reef transport timeout changes remain (no unrelated daemon files). All CI green.

Evidence summary

  • ✅ 10/10 tests pass including stall-timeout test
  • ✅ Controlled relay proof: healthy pull succeeds, stalled request times out, oversized JSON rejected, backoff recovers
  • ✅ oxfmt --check: clean
  • ✅ git diff --check: clean
  • ✅ CI: auto-response SUCCESS, Real behavior proof SUCCESS, openclaw/ci-gate SUCCESS

@clawsweeper re-review

@steipete steipete self-assigned this Jul 18, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jul 18, 2026
@cxbAsDev

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Branch is reef-only with all CI green. Real behavior proof in PR body (stall-timeout + bounded JSON relay reads). Ready for re-review.

@clawsweeper

clawsweeper Bot commented Jul 18, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jul 18, 2026
Co-authored-by: 陈宪彪0668000387 <[email protected]>
@steipete
steipete force-pushed the fix/reef-relay-transport-timeout branch from bb059df to b94da60 Compare July 18, 2026 08:12
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Jul 18, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jul 18, 2026
@steipete
steipete merged commit af2662f into openclaw:main Jul 18, 2026
92 of 94 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: reef Channel integration: reef merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S 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