Raise RPC WebSocket ping interval to prevent reconnect loop on large workspaces #3500
main fromrefs/pull/3500/head·opened View on GitHubWhat Changed#
Raise the Effect RPC client WebSocket ping interval from 5s to 45s, via the existing effect patch (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 (makePinger in effect's dist/unstable/rpc/RpcClient.js) pings every 5s and tears down the transport if the peer
doesn'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-closed with aliveMs ≈ 13000, roughly one per ~13–26s; the client side reports
ConnectionTransientError 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 git spawns) and/or expose the ping interval as a makeProtocolSocket option upstream in Effect instead of hard-coding it in a
vendored patch. Happy to take it in either direction.
Checklist#
- This PR is small and focused
- I explained what changed and why
- I included before/after screenshots for any UI changes — N/A, no UI changes
- I included a video for animation/interaction changes — N/A
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.78 pnpm patch so the RPC socket client’s makePinger loop 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 RpcClient customizations (request/connection hooks, ping-timeout handling) and pnpm-lock.yaml is updated so every workspace consumer picks up the new patch hash.
Note
Raise RPC WebSocket ping interval from 5s to 45s to prevent reconnect loops on large workspaces#
- Increases the heartbeat ping interval in
RpcClient.makeProtocolSocketfrom 5 seconds to 45 seconds, preventing frequent reconnects on large workspaces where ping/pong round-trips may take longer. - Adds an optional
onPinghook via a newConnectionHookscontext tag, allowing callers to run an effect before each ping is sent. - Exports
ConnectionHooksandlayerHookfrom theRpcClientmodule so consumers can register hooks at the call site. - The returned socket object now includes a
resetfunction (exposed aslatch.await) alongsidetimeout.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
Approvability#
Verdict: 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](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).I confirmed the 5-second heartbeat failure this PR addresses on v0.0.28, using a macOS desktop client and a remote Linux server over both Tailscale and Cloudflare.
The WebSocket handshake and
server.getConfigsucceeded, but eager thread hydration produced 1.28 MB and 2.27 MB frames, with another subscribed thread having a 69.9 MB cached snapshot. The client sent its first RPCPingwhile those ordered frames were still draining; thePongdid not arrive within five seconds, so the client reconnected and repeated the same hydration cycle. Loopback remained healthy because it drained the initial state quickly.As a workaround, archiving the three heavy, stopped threads appears to have stopped the reconnect loop for me. I have not tested this branch directly, but raising the interval to 45 seconds matches the observed failure and should provide an effective mitigation. However, I think a more structural solution should be sought for this.
Closing in favor of author-designated replacement #3817, which carries the same heartbeat mitigation with the maintained 60-second value.
juliusmarminge closed this
Sign in to join this conversation.
Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID:
0148dc55-c6eb-4645-973e-e54a430434b5You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.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.
❤️ Share