Skip to content

fix(browser): report malformed relay CDP frames#102070

Merged
steipete merged 2 commits into
openclaw:mainfrom
qingminglong:codex/cxb-102057-browser-relay-cdp-error
Jul 9, 2026
Merged

fix(browser): report malformed relay CDP frames#102070
steipete merged 2 commits into
openclaw:mainfrom
qingminglong:codex/cxb-102057-browser-relay-cdp-error

Conversation

@qingminglong

Copy link
Copy Markdown
Contributor

Closes #102057

What Problem This Solves

Fixes an issue where browser extension relay CDP clients would keep waiting when they sent malformed JSON or a structurally invalid CDP request frame.

Why This Change Was Made

The relay now validates inbound CDP client frames at the socket boundary and returns JSON-RPC parse or invalid-request errors instead of silently dropping those frames. Valid CDP requests continue through the existing request handler unchanged.

User Impact

Automation clients connected through the browser extension relay now receive immediate protocol errors for malformed client frames instead of timing out without a response.

Evidence

  • Current-main source check: extensions/browser/src/browser/extension-relay/relay-bridge.ts previously returned silently when JSON.parse(raw) failed or when the parsed request lacked numeric id / string method.
  • Focused regression: node scripts/run-vitest.mjs extensions/browser/src/browser/extension-relay/relay-bridge.test.ts passed in the first issue worktree after dependency hydration: 1 file, 12 tests.
  • Clean worktree proof: git diff --check HEAD~1..HEAD passed.
  • Format proof: pnpm dlx [email protected] --check --threads=1 extensions/browser/src/browser/extension-relay/relay-bridge.ts extensions/browser/src/browser/extension-relay/relay-bridge.test.ts passed.
  • Closeout review: python .agents\skills\autoreview\scripts\autoreview --mode local reported no accepted/actionable findings before commit.

@clawsweeper

clawsweeper Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 8, 2026, 4:02 AM ET / 08:02 UTC.

Summary
The PR adds CDP client-frame parsing and validation in the browser extension relay, returning JSON-RPC errors for malformed JSON or invalid request objects with focused relay-bridge tests.

PR surface: Source +29, Tests +28. Total +57 across 2 files.

Reproducibility: yes. Current main has a high-confidence source-level reproduction path: attach a CDP client through ExtensionRelayBridge.attachCdpClientSocket and send malformed JSON or an object without numeric id plus string method; the handler returns before sending a response.

Review metrics: none identified.

Stored data model
Persistent data-model change detected: serialized state: extensions/browser/src/browser/extension-relay/relay-bridge.test.ts, serialized state: extensions/browser/src/browser/extension-relay/relay-bridge.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #102057
Summary: The canonical user problem is the browser relay malformed-frame bug; this PR and one sibling PR are separate candidate fixes for that same issue.

Members:

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

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🐚 platinum hermit
Patch quality: 🦞 diamond lobster
Result: ready for maintainer review.

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

Rank-up moves:

  • none.

Risk before merge

  • [P1] Another open candidate PR targets the same linked issue; maintainers should land one focused relay-boundary fix and close or supersede the other rather than merging both.

Maintainer options:

  1. Decide the mitigation before merge
    Land this focused relay-boundary fix, or an equivalent one, for [Bug]: browser extension relay leaves CDP clients waiting when malformed frames arrive #102057 and then close or supersede the overlapping candidate at fix(browser): return JSON-RPC errors for malformed CDP client frames in relay bridge #102071.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • [P2] No repair job is needed; the PR is proof-positive and has no blocking review findings, leaving normal maintainer landing and duplicate-candidate coordination.

Security
Cleared: Cleared: the diff only changes browser relay TypeScript logic and colocated tests, with no dependency, workflow, credential, permission, or package-resolution changes.

Review details

Best possible solution:

Land this focused relay-boundary fix, or an equivalent one, for #102057 and then close or supersede the overlapping candidate at #102071.

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

Yes. Current main has a high-confidence source-level reproduction path: attach a CDP client through ExtensionRelayBridge.attachCdpClientSocket and send malformed JSON or an object without numeric id plus string method; the handler returns before sending a response.

Is this the best way to solve the issue?

Yes. The PR fixes the implicated CDP client socket boundary, preserves id/sessionId in invalid-request errors, and leaves normal handleCdpRequest routing unchanged.

AGENTS.md: found and applied where relevant.

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

Label changes

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The contributor supplied a redacted exact-head live loopback WebSocket transcript showing malformed JSON and invalid request frames receive immediate JSON-RPC errors.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The contributor supplied a redacted exact-head live loopback WebSocket transcript showing malformed JSON and invalid request frames receive immediate JSON-RPC errors.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This is a focused browser relay bug fix with limited blast radius: malformed CDP frames can leave automation clients waiting for their own timeout.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The contributor supplied a redacted exact-head live loopback WebSocket transcript showing malformed JSON and invalid request frames receive immediate JSON-RPC errors.
  • proof: sufficient: Contributor real behavior proof is sufficient. The contributor supplied a redacted exact-head live loopback WebSocket transcript showing malformed JSON and invalid request frames receive immediate JSON-RPC errors.
Evidence reviewed

PR surface:

Source +29, Tests +28. Total +57 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 38 9 +29
Tests 1 28 0 +28
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 66 9 +57

What I checked:

Likely related people:

  • vincentkoc: Blame for the current CDP client handler points to a Vincent Koc merge commit in the available checkout, and live PR metadata links that commit to a recent browser-adjacent OpenClaw PR. (role: introduced behavior and recent area contributor; confidence: medium; commits: 3dbe98a1f737; files: extensions/browser/src/browser/extension-relay/relay-bridge.ts, extensions/browser/src/browser/extension-relay/relay-bridge.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.
Review history (1 earlier review cycle)
  • reviewed 2026-07-08T07:10:50.323Z sha ae2425f :: needs real behavior proof before merge. :: none

@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. P2 Normal backlog priority with limited blast radius. labels Jul 8, 2026
@qingminglong

Copy link
Copy Markdown
Contributor Author

Added the missing real behavior proof for this exact head.

Head verified: ae2425f414fdf2a6fd84a4841a0b7853a78c9ddf

Environment and safety notes:

  • Repo root: E:/code/openclaw
  • Local worktree stayed clean before/after proof.
  • Crabbox/Testbox was not available here (crabbox command not found), so I did not run repo pnpm scripts or broad tests against the external fork checkout.
  • Instead I used a self-contained Node built-in harness: git show loaded extensions/browser/src/browser/extension-relay/relay-bridge.ts from the exact PR commit, Node stripTypeScriptTypes transformed it, unrelated logging/protocol imports were stubbed, and a real loopback HTTP upgrade plus raw TCP WebSocket CDP client exercised ExtensionRelayBridge.attachCdpClientSocket(...) through /cdp-style WebSocket frames.

Command shape, from repo root:

# Inline Node harness piped to node from PowerShell.
# The harness asserted:
#   git rev-parse upstream/pr/102070 == ae2425f414fdf2a6fd84a4841a0b7853a78c9ddf
# It then loaded the bridge source with:
#   git show ae2425f414fdf2a6fd84a4841a0b7853a78c9ddf:extensions/browser/src/browser/extension-relay/relay-bridge.ts
# It started a loopback HTTP upgrade server wired to ExtensionRelayBridge.attachCdpClientSocket,
# connected a raw TCP WebSocket client, sent the two bad text frames, and asserted each
# response arrived within 500ms with the expected JSON-RPC id/code/message.

Redacted transcript:

{
  "proof": "live loopback WebSocket /cdp client against ExtensionRelayBridge.attachCdpClientSocket",
  "head": "ae2425f414fdf2a6fd84a4841a0b7853a78c9ddf",
  "node": "v22.20.0",
  "timeoutBudgetMs": 500,
  "transcript": [
    {
      "case": "malformed JSON",
      "sent": "<malformed JSON frame, redacted body>",
      "responseMs": 16,
      "response": {
        "id": null,
        "error": {
          "code": -32700,
          "message": "Parse error"
        }
      }
    },
    {
      "case": "invalid request frame",
      "sent": "<JSON object missing method, params redacted>",
      "responseMs": 15,
      "response": {
        "id": 42,
        "error": {
          "code": -32600,
          "message": "Invalid request"
        }
      }
    }
  ]
}

This proves the malformed JSON and invalid request frames now receive immediate JSON-RPC errors instead of waiting for a client-side timeout. I only looked at #102071 enough to confirm it is still an overlapping open PR for the same issue; I did not touch it.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 8, 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.

@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. and removed 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. labels Jul 8, 2026
@steipete steipete self-assigned this Jul 9, 2026
@steipete
steipete force-pushed the codex/cxb-102057-browser-relay-cdp-error branch from ae2425f to fc389e1 Compare July 9, 2026 10:48
@steipete

steipete commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Maintainer follow-up complete. I kept the contributor's regression coverage, collapsed the parser abstraction into one relay validation path, and preserved numeric request ids plus flat CDP sessionId values so Playwright routes failures to the correct pending callback.

Verification:

  • Sanitized AWS fresh-PR bootstrap at ae2425f414f: 12/12 relay tests passed (run_52f36fe1e330).
  • Blacksmith Testbox on the maintainer fixup: 12/12 relay tests passed (tbx_01kx372nrwbsqzdebwhpym9xgm, Actions run 29012043047).
  • Real authenticated relay/WebSocket exchange on Testbox tbx_01kx37hyr09nst7sf6pa4sj6nw: malformed JSON returned -32700; an invalid request returned -32600 while preserving sessionId=flat-1; a valid Browser.getVersion request still returned protocol 1.3.
  • Fresh autoreview: no actionable findings, correctness confidence 0.99.
  • Exact PR head fc389e19108b7dffe0cedfaaaa0f84901bf4b0ae: full CI passed.

This fixes the hang without changing relay authentication, frame-size limits, extension routing, or valid CDP behavior. Ready to merge.

@steipete
steipete merged commit 56096eb into openclaw:main Jul 9, 2026
89 checks passed
@steipete

steipete commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 10, 2026
* fix(browser): report malformed relay CDP frames

* refactor(browser): streamline relay frame validation

---------

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

Labels

P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: browser extension relay leaves CDP clients waiting when malformed frames arrive

2 participants