fix(web): recover silently-dead SSE connections quickly, stop banner noise (#1562)

A suspended mobile tab can lose its SSE connection without the browser
ever noticing (no FIN/RST arrives). On resume the client used to wait
for the 90s heartbeat watchdog or lean on the native EventSource retry,
which can hang on a dead pooled socket - leaving a persistent
"Reconnecting... (stream error)" banner while the UI keeps working.

- useSSE: on visibility resume, distrust the connection after one missed
  heartbeat interval (45s) instead of 90s
- useSSE: abandon connection attempts that don't open within 10s (hung
  on a dead pooled socket after resume) instead of waiting for the
  watchdog; force bypasses the one-shot reconnect guard for the new
  attempt cycle
- useSSE: first reconnect attempt is immediate; exponential backoff
  starts from the second attempt
- ReconnectingBanner: localize connect-timeout and transport-error
  reasons (transport-error is already emitted by current code but fell
  through unlabeled)

Fixes #1559. Reimplements the reconnect half of #989 (closed unmerged)
on top of the current scheduler (hidden-tab deferral, slow backoff,
replay cursor).
This commit is contained in:
SSU-WEI HUANG
2026-08-15 11:16:19 +08:00
committed by GitHub
parent 235d6dd6fd
commit a794be0811
5 changed files with 202 additions and 8 deletions
@@ -7,6 +7,12 @@ function getReasonLabel(reason: string, t: (key: string) => string): string {
if (reason === 'visibility-recovery') {
return t('reconnecting.reason.visibilityRecovery')
}
if (reason === 'connect-timeout') {
return t('reconnecting.reason.connectTimeout')
}
if (reason === 'transport-error') {
return t('reconnecting.reason.transportError')
}
if (reason === 'closed') {
return t('reconnecting.reason.closed')
}