Commit ec1bcde
committed
fix(web): connection health poll silently erased the escalated "down" state
useLiveStream's health-poll effect (every 10s) unconditionally reset
attemptsRef to 0 and overwrote `connection` on every successful
GET /api/health — regardless of whether the actual EventSource was open.
Since a plain health check answering says nothing about the SSE stream
itself, this meant that a few seconds after the UI escalated to "down"
(after 3 consecutive stream failures), the next poll tick would silently
flip it back to "reconnecting" and reset the reconnect backoff to its
fastest delay — so a user watching the connection badge would almost never
actually see "down", losing the signal exactly when the stream had been
failing repeatedly.
Also fixed connect() itself, which set connection to 'reconnecting' on
every dispatched retry attempt without checking whether attempts had
already crossed the DOWN_AFTER_ATTEMPTS threshold — the same downgrade bug
via a different path.
Now the poll only promotes state (and resets backoff) when the EventSource
is genuinely OPEN; otherwise it leaves the EventSource's own onerror/onopen
handlers as the sole source of truth for connection state.
Caught by web/src/hooks/useLiveStream.test.tsx ("escalates to down after
repeated failures and resumes from the last seq"), which was failing on
main before this change.1 parent 6e1efe9 commit ec1bcde
1 file changed
Lines changed: 24 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
160 | 160 | | |
161 | 161 | | |
162 | 162 | | |
163 | | - | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
164 | 175 | | |
165 | 176 | | |
166 | 177 | | |
| |||
314 | 325 | | |
315 | 326 | | |
316 | 327 | | |
317 | | - | |
318 | 328 | | |
319 | | - | |
320 | | - | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
321 | 341 | | |
322 | 342 | | |
323 | 343 | | |
| |||
0 commit comments