Raise RPC WebSocket ping interval to prevent reconnect loop on large workspaces#3500
Raise RPC WebSocket ping interval to prevent reconnect loop on large workspaces#3500mincua wants to merge 1 commit into
Conversation
…workspaces The Effect RPC client pinger (makePinger in effect's RpcClient) pings every 5s and tears down the WebSocket if the peer does not answer within that window. On a large workspace, opening a thread keeps the server event loop busy for ~10-15s (per-project VCS/git status, repository detection, and favicon resolution across every sidebar project), so the server misses the ping, the client drops the transport and reconnects, the reconnect restarts the same heavy load, the next ping is missed, and the connection loops indefinitely — the thread never opens. Raise the ping interval to 45s via the existing effect patch so the connection survives a busy-but-alive backend. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
ApprovabilityVerdict: Approved This PR makes a single, clear timing change - raising the WebSocket ping interval from 5 to 45 seconds to fix reconnect loops. The lockfile changes are mechanical hash updates from the patch modification. Low-risk configuration tweak with clear bug-fix intent. You can customize Macroscope's approvability policy. Learn more. |
What Changed
Raise the Effect RPC client WebSocket ping interval from 5s to 45s, via the existing
effectpatch (patches/effect@4.0.0-beta.78.patch).One-line keepalive change; no source or behavior changes beyond the ping cadence.
Why
Opening a thread on a large workspace drops the app into an endless WebSocket disconnect/reconnect loop, and the thread never becomes usable.
The Effect RPC client pinger (
makePingerineffect'sdist/unstable/rpc/RpcClient.js) pings every 5s and tears down the transport if the peerdoesn't answer within that window. Opening a thread keeps the server event loop busy for ~10–15s — per-project VCS/git status, repository detection,
and favicon resolution across every sidebar project (scales with project count and repo size). The server misses the ping, the client declares the
transport dead and reconnects, the reconnect restarts the same heavy load, the next ping is missed, and it loops.
Confirmed from logs: each WS session ends
clean-client-closedwithaliveMs ≈ 13000, roughly one per ~13–26s; the client side reportsConnectionTransientError reason:"transport"at ~10s, repeatedly. The backend PID stays stable (not a process restart) and the establishment /socket-open timeouts are never reached — only the 5s ping is. Raising it to 45s lets the connection survive a busy-but-alive backend.
A more thorough fix would keep the event loop responsive during thread load (cache/dedup the per-project VCS detection and favicon resolution, and
bound concurrent
gitspawns) and/or expose the ping interval as amakeProtocolSocketoption upstream in Effect instead of hard-coding it in avendored patch. Happy to take it in either direction.
Checklist
Note
Medium Risk
Changes keepalive behavior for all Effect RPC WebSocket clients monorepo-wide; slower ping failure detection trades off against fewer false disconnects on a loaded backend.
Overview
Updates the vendored
effect@4.0.0-beta.78pnpm patch so the RPC socket client’smakePingerloop waits 45 seconds between pings instead of 5 seconds, giving the server more time to answer while the event loop is busy (e.g. heavy thread/workspace load) before the client treats the transport as dead and reconnects.The patch refresh also carries the repo’s other
RpcClientcustomizations (request/connection hooks, ping-timeout handling) andpnpm-lock.yamlis updated so every workspace consumer picks up the new patch hash.Reviewed by Cursor Bugbot for commit 01bf240. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Raise RPC WebSocket ping interval from 5s to 45s to prevent reconnect loops on large workspaces
RpcClient.makeProtocolSocketfrom 5 seconds to 45 seconds, preventing frequent reconnects on large workspaces where ping/pong round-trips may take longer.onPinghook via a newConnectionHookscontext tag, allowing callers to run an effect before each ping is sent.ConnectionHooksandlayerHookfrom theRpcClientmodule so consumers can register hooks at the call site.resetfunction (exposed aslatch.await) alongsidetimeout.Macroscope summarized 01bf240.