Commit b4ff5f5
committed
fix(app): reduce spurious SSE reconnects after sleep/resume
Two changes to improve connection stability when a device resumes from
sleep or a browser tab returns from background:
1. Increase HEARTBEAT_TIMEOUT_MS from 15s to 30s. The server sends
heartbeats every 10s, so 15s left only 5s of margin — under load or
network jitter a heartbeat could arrive late and trigger a premature
disconnect. 30s provides a comfortable 20s buffer while still
detecting genuinely dead connections.
2. On visibilitychange, reset the heartbeat timer instead of immediately
aborting. Previously, returning to a backgrounded tab after >15s would
instantly abort the SSE connection and trigger a full reconnect cycle
(re-bootstrap all directories). Now the stream gets one full heartbeat
interval to prove it's still alive. If no event arrives within the
timeout, the timer fires and aborts — same end result but without
false positives for connections that are still healthy.1 parent f54abe5 commit b4ff5f5
1 file changed
Lines changed: 11 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
108 | | - | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
109 | 113 | | |
110 | 114 | | |
111 | 115 | | |
| |||
190 | 194 | | |
191 | 195 | | |
192 | 196 | | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
193 | 202 | | |
194 | 203 | | |
195 | 204 | | |
196 | 205 | | |
197 | | - | |
| 206 | + | |
198 | 207 | | |
199 | 208 | | |
200 | 209 | | |
| |||
0 commit comments