fix: fix devtunnel WebSocket disconnects and reconnect reliability#2547
fix: fix devtunnel WebSocket disconnects and reconnect reliability#2547IcyHot09 wants to merge 6 commits intopingdotgg:mainfrom
Conversation
…tion Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Remove the 7-retry cap (Schedule.recurs → Schedule.forever) so the WebSocket protocol never enters the "exhausted" dead state. Add a visibility guard in onPingTimeout to suppress false-positive heartbeat timeouts when the browser tab is backgrounded. Remove the "exhausted" phase from WsReconnectPhase and all related UI logic. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…orm-bun patch Reduces JSON payload size 60-80% to prevent SSH window saturation through devtunnel. Adds @effect/platform-bun patch that sets perMessageDeflate: true in the Bun.serve() websocket handler. Co-Authored-By: Claude Sonnet 4.6 <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)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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 |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 6f364eb. Configure here.
ApprovabilityVerdict: Needs human review This PR fundamentally changes WebSocket reconnection behavior from finite retries to infinite, adds stream throttling, visibility-based reconnect logic, and enables WebSocket compression via a vendor patch. These are significant runtime behavior changes that warrant careful human review despite the fix-framed title. You can customize Macroscope's approvability policy. Learn more. |
…ibility Replaces the single _wakeReconnect slot with a Set so every subscription sleeping through a congestion delay gets woken when the tab becomes visible, not just the last one to register. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

What Changed
Stream.throttleto terminal, git progress, and shell snapshot streams to reduce burst rateperMessageDeflateWebSocket compression via@effect/platform-bunpatch (60-80% payload reduction)Why
When accessing T3 remotely via Microsoft devtunnel, the WebSocket connection
disconnects and reconnects every 2-3 seconds during normal use. Opening sessions
with large chat histories makes it worse — the initial snapshot load can sustain
the disconnect for 20+ seconds.
Root cause: devtunnel relays traffic over an SSH channel with a hardcoded 1 MB
window. Any burst of outbound data (terminal output, session snapshots, git
progress events) fills the window faster than the client can drain it. This
stalls all WebSocket frames including heartbeat ping/pong, triggering a timeout
disconnect. After 7 retries (~127s) the client entered a permanent "exhausted"
state and stopped trying — requiring a manual page refresh.
The throttling and compression reduce sustained burst rates below the saturation
threshold. The unlimited-retry fix ensures recovery when a burst does cause a
disconnect.
Checklist
Note
Medium Risk
Changes core WebSocket reconnect/backoff and subscription retry behavior, which can affect connectivity and resource usage under failure conditions. Server-side throttling and compression also alter runtime performance characteristics and could surface regressions in stream delivery timing.
Overview
Improves WebSocket stability under high-throughput conditions by throttling several high-volume server streams (orchestration shell snapshot/events, git action progress, terminal events) to smooth bursts.
On the client, removes the capped retry/
exhaustedreconnect state and switches protocol retry policy to retry forever, with updated state/tests and UI toasts (no max-attempt display, no exhausted toast).Adds guards to reduce false disconnects and speed recovery: suppresses heartbeat timeout handling when the tab is hidden, and updates
WsTransportsubscription retries with a congestion-aware minimum delay plus avisibilitychangewake-up. Enables WebSocketperMessageDeflatevia an@effect/platform-bunpatch (and bumps package versions/lockfile accordingly).Reviewed by Cursor Bugbot for commit b318893. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Fix WebSocket disconnect/no-reconnect loop when loading large sessions
WsTransportretry indefinitely using exponential backoff instead of entering an exhausted/dead statevisibilitychangelistener so reconnect sleeps wake immediately when the tab becomes visible againperMessageDeflateon the Bun WebSocket server via a patch to reduce wire payload sizeMacroscope summarized b318893.