Repository navigation
fix(web): back off events ticket retries while the server is down - #5593
Conversation
A failed events-socket ticket mint was retried every second for as long as the server stayed unreachable. The wait now doubles from 1 to 30 seconds with jitter, honours a refused mint's Retry-After (capped at 60 seconds), and starts over once a socket receives hello. Closes Silo-Server#5569
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
/silo reviewReviewed head: Fit: 9/10 · Readiness: 9/10 — ready The fix holds up. While the ticket mint fails, the web events socket now backs off from 1 s to 30 s with jitter instead of retrying every second. I reproduced the storm on the PR's base and saw it gone on the head. I found no defect to fix and pushed no commits. Verification
Evidence: https://evidence.siloserver.org/r/silo-server/pr-5593/ What I checked and left as is
Validation
Other clients and docs
CouncilOne round on this head, every member at medium effort:
Kody and CodeRabbit left no inline findings. 🤖 Claude Code (claude-opus-5-5) |
Main changed RealtimeEventsProvider.tsx and its tests (Silo-Server#5593) since this branch's merge base. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Problem
Closes #5569
Related issue: N/A
Validation tasks: changes #1235 C2 (Notifications — Web), whose live delivery rides the events socket. The normal connect path is unchanged; only the wait after a failed mint or a dropped socket changes.
Other clients: Apple N/A (its home watch-state events socket already doubles its retry from 1 to 30 seconds); Android N/A (already backs off from 1 to 30 seconds); Roku N/A (home watch socket already doubles its retry up to a cap)
While Silo is unreachable, a web tab asks for a new events-socket ticket (
POST /api/v2/events/ws-ticket) every second until the server comes back. In the issue that came to 120 requests in two minutes from one tab during a restart. The web app now waits longer after each failure in a row, takes a random part off each wait so dropped tabs don't all come back in the same second, and never retries sooner than a refused mint'sRetry-After.Approach
The events provider's reconnect wait now starts at 1 second and doubles to 30 seconds. Jitter takes up to half of each wait off. A
Retry-Afteron a refused mint sets the minimum wait, capped at 60 seconds, as the playback-control socket already does. The count of failures resets when a socket receiveshello, so a socket that drops after a healthy session reconnects within a second, as before. Close codes that already set their own wait keep it:4001reconnects at once,4002waits 30 seconds,4004waits 5 seconds, and theprofile_requiredrebind keeps its 5-minute backoff.docs/realtime-api.mdnow states the web app's events reconnect timing, which it did not before.The playback-control socket keeps its own step table and gets no jitter here. A shared helper for both sockets would be a separate change.
Validation
Retry-Afterholds the next mint back; a socket that getshelloresets the wait. All 47 tests in the file pass.hello,subscribedandsnapshot.pnpm run lint,pnpm run format:check,tsc -p tsconfig.app.json,pnpm run build,pnpm run budget:check,make test-webpass.make verify-local-paths,make verify-size-ratchet,make verify-bidi,make verify-case-collisionspass. The Go checks were not run because no Go code changed.Evidence
Nothing on screen changes. These are the ticket requests a logged-in tab sent during each 60-second outage, on the same local build and data before and after the fix.
Risks
After a long outage, a tab can take up to 30 seconds to reconnect once the server is back, or 60 seconds when the server sent a longer
Retry-After. Before this change it took about a second. Live updates in that tab catch up when it reconnects.Checklist
AI Disclosure
Retry-Afterruns out. That is one request per return to the tab, not a retry loop, and older versions behaved the same way. Left as is: theRetry-Aftercap rule now exists in both socket hooks, which use different step tables on purpose.Note
Add jittered exponential backoff for events ticket retries in
RealtimeEventsProviderRetry-Afteris honored up to a 60s cap when it exceeds the computed delay.Retry-Afterhandling, and hello-based reset in RealtimeEventsProvider.test.tsx, and documents the retry behavior in realtime-api.md.Macroscope summarized 9654010.