Skip to content

fix(gateway): update handshake protocol to v4 - #367

Open
LAIM69420 wants to merge 1 commit into
daggerhashimoto:masterfrom
LAIM69420:fix/gateway-protocol-v4
Open

fix(gateway): update handshake protocol to v4#367
LAIM69420 wants to merge 1 commit into
daggerhashimoto:masterfrom
LAIM69420:fix/gateway-protocol-v4

Conversation

@LAIM69420

@LAIM69420 LAIM69420 commented Jul 12, 2026

Copy link
Copy Markdown

Fix gateway handshake compatibility with OpenClaw protocol v4

Closes #361.

What changed

  • advertise gateway protocol 4 in the browser WebSocket handshake
  • advertise gateway protocol 4 in the server-side RPC handshake
  • assert the protocol range in both existing handshake test suites

Why

Current OpenClaw gateways require protocol 4. Nerve advertised only protocol 3 from both connection implementations, so the gateway closed the WebSocket with code 1002 before authentication completed.

Verification

  • npx vitest run src/hooks/useWebSocket.test.ts server/lib/gateway-rpc.test.ts — 37 passed
  • scoped ESLint — passed
  • git diff --check — passed
  • full suite — 1,869 passed, 1 unrelated existing failure in server/routes/gateway.test.ts (node:child_process mock has no default export)
  • full build remains blocked by existing strict-null TypeScript errors in cron, kanban, sessions, and workspace routes

Summary by CodeRabbit

  • Enhancements

    • Updated WebSocket and gateway connections to use protocol version 4 during the connection handshake.
    • Improved compatibility between clients and gateways using the updated protocol range.
  • Tests

    • Added coverage to verify that connection handshakes include the required protocol version parameters.

@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 43543b58-8fba-4f84-a31e-f6162714b5bf

📥 Commits

Reviewing files that changed from the base of the PR and between 312e273 and c36a34b.

📒 Files selected for processing (4)
  • server/lib/gateway-rpc.test.ts
  • server/lib/gateway-rpc.ts
  • src/hooks/useWebSocket.test.ts
  • src/hooks/useWebSocket.ts

📝 Walkthrough

Walkthrough

The WebSocket client and gateway RPC handshake protocol bounds were changed from version 3 to version 4. Client and server handshake tests now assert the updated protocol parameters.

Changes

Protocol v4 handshake

Layer / File(s) Summary
Align handshake negotiation and coverage
src/hooks/useWebSocket.ts, server/lib/gateway-rpc.ts, src/hooks/useWebSocket.test.ts, server/lib/gateway-rpc.test.ts
Client and gateway RPC connections now require protocol version 4, with tests asserting minProtocol: 4 and maxProtocol: 4.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly states the main change: updating the gateway handshake protocol to v4.
Description check ✅ Passed The PR includes What, Why, and Verification details and is mostly complete despite omitting the template's Type of Change and Screenshots sections.
Linked Issues check ✅ Passed The code updates both handshake paths to protocol 4 and adds tests, matching issue #361's protocol-mismatch fix.
Out of Scope Changes check ✅ Passed All changes support the handshake version bump; no unrelated code or features were introduced.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]

1 participant