Skip to content

fix: 5994 silent WebSocket reconnects#5996

Merged
Pyatakov merged 1 commit intodevelopfrom
fix/websocket-silent-reconnect
Apr 24, 2026
Merged

fix: 5994 silent WebSocket reconnects#5996
Pyatakov merged 1 commit intodevelopfrom
fix/websocket-silent-reconnect

Conversation

@Pyatakov
Copy link
Copy Markdown
Contributor

Description

The frontend shows a red Close Web Socket ws://localhost:3000 error toast every time the WebSocket connection drops – typically after tab inactivity, a quick network blip, or a backend restart. The toast fires immediately on disconnect even though the service already silently retries every 5s (up to 10 attempts). In the vast majority of cases the reconnect succeeds within a few seconds, so users see a scary toast displaying a raw developer-facing URL for an issue that has already self-healed. Multiple drops can stack toasts on top of each other.

This fix introduces a small state machine around reconnection that suppresses UI during the expected silent-retry window and only surfaces notifications when the outage is long enough to matter:

Phase Trigger User sees
Silent retry First ~15s after disconnect (3 attempts @ 5s) Nothing
Warning Still disconnected after grace period Info toast: "Connection lost. Trying to reconnect…" (sticky, auto-dismissed on recovery)
Recovered (after warning) openWebSocket() fires while warning is visible Warning clears, brief green "Connection restored" (2s)
Recovered silently Reconnect inside grace window Nothing
Gave up All 10 retries exhausted (~50s) Error toast: "Unable to reconnect to the server. Please check your network connection and refresh the page." (persistent, close button)

User-facing notification is now free of raw ws://… URLs.

Related issue(s)

Fixes #5994

Notes for reviewers

  • Grace period (15s) and retry count (10) are intentionally independent – if retry parameters are tuned later, the grace period still caps how long before we tell the user anything.
  • The final "Unable to reconnect" toast is persistent with a close button, so it won't disappear before the user notices.

Checklist

  • Documented (Code comments, README, etc.)
  • Tested (unit, integration, etc.)

Previously, any WebSocket close fired a red "Close Web Socket
ws://localhost:3000" toast immediately, even though silent retries
(5s interval, 10 attempts) usually recovered within seconds —
especially after tab inactivity.

Now the service retries silently for a 15s grace period before
showing a single non-alarming info toast ("Connection lost —
Trying to reconnect…"), which clears on successful reconnect and
is briefly replaced by a "Connection restored" confirmation. Only
when all attempts are exhausted does a user-friendly error toast
appear asking the user to check their network and refresh.

Signed-off-by: Alex Piatakov <alex.piatakov@swirldslabs.com>
@Pyatakov Pyatakov requested review from a team as code owners April 24, 2026 21:28
@Pyatakov Pyatakov self-assigned this Apr 24, 2026
@github-actions
Copy link
Copy Markdown

Test Results

 32 files  ±0   64 suites  ±0   8m 15s ⏱️ +4s
 35 tests ±0   35 ✅ ±0  0 💤 ±0  0 ❌ ±0 
165 runs  ±0  165 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit 582da05. ± Comparison against base commit 1fa9ec8.

@Pyatakov Pyatakov merged commit ea59d9d into develop Apr 24, 2026
20 of 23 checks passed
@Pyatakov Pyatakov deleted the fix/websocket-silent-reconnect branch April 24, 2026 23:30
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