Skip to content

[ID-1669] Keep quiet EVM WebSocket connections responsive - #13

Merged
Ri-go merged 2 commits into
masterfrom
id-1669-evm-websocket-heartbeat
Oct 5, 2026
Merged

Ri-go merged 2 commits into
masterfrom
id-1669-evm-websocket-heartbeat

Conversation

@Ri-go

@Ri-go Ri-go commented Oct 5, 2026 •

Copy link
Copy Markdown
Member

Quiet native EVM WebSocket clients without TCP keepalive stopped responding after six minutes through OVH, while the same source Caddy and private Service tests passed. Send an empty downstream Ping every 20 seconds so quiet connections continue carrying traffic through the public proxy path.

The EVM listener uses Gorilla's concurrent-safe control writer with a five-second budget, closes the client on write failure, and stops and joins the heartbeat before unregistering the handler. No Pong deadline is added; subscription routing and other listeners are unchanged.

Validation:

  • Full race suite: go test -mod=readonly -race -count=1 -timeout=10m ./....
  • go vet ./... and go build -mod=readonly -o /tmp/stitch-id-1669 ./cmd/stitch.
  • Quiet subscription behind an idle-expiring TCP proxy, including a failing control without heartbeat and post-idle unsubscribe, newHeads, and chainId checks.
  • Concurrent RPC/notification identity checks and client-close, upstream-close, shutdown, and injected Ping write failure cleanup.

The six-minute public test with TCP keepalive disabled must pass after deployment before DNS cutover.

ID-1669

@linear

linear Bot commented Oct 5, 2026

Copy link
Copy Markdown

ID-1669

@coderabbitai

coderabbitai Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: 09404c07-e4ca-46da-bca6-4d9d255741eb
📥 Commits

Reviewing files that changed from the base of the PR and between 9a5521c and dea4b37.

📒 Files selected for processing (2)
  • internal/server/eth_ws/heartbeat_test.go
  • internal/server/eth_ws/server.go

Included review availability: This review used your included allowance. 1 included review remains after this review. Your included PR review attempts over the past 7 days set your current allowance at 5 reviews per hour.


📝 Walkthrough

Walkthrough

The WebSocket server now sends client Ping control frames every 20 seconds with a 5-second write deadline. It stops the ping goroutine when the handler exits. Tests cover quiet proxy connections, concurrent RPC and subscription traffic, and session termination.

Changes

WebSocket client heartbeat

Layer / File(s) Summary
Send and stop client heartbeats
internal/server/eth_ws/server.go
The server initializes heartbeat timing, starts a ping goroutine for each upgraded connection, and stops it when the handler exits. A failed Ping write closes the client connection.
Verify heartbeat and connection lifecycle
internal/server/eth_ws/heartbeat_test.go
Tests cover heartbeat behavior through an idle-expiring proxy, concurrent RPC calls and subscription notifications, and shutdown after client closure, upstream closure, server shutdown, or a Ping write failure.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant ServeHTTP
  participant pingClient
  participant TCPIdleProxy
  participant WebSocketClient
  ServeHTTP->>pingClient: Start heartbeat goroutine
  pingClient->>TCPIdleProxy: Send Ping frame
  TCPIdleProxy->>WebSocketClient: Forward Ping frame
Loading

Merge Risk: ⚪ Minimal · up to dea4b

No merge-blocking issue is identified. Complete the planned public-connection test before DNS cutover.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 9.09% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: keeping quiet EVM WebSocket connections responsive.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@Ri-go
Ri-go merged commit e1523bb into master Oct 5, 2026
11 of 13 checks passed
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.

1 participant