Does htmx's SSE extension guarantee reconnection after browser tab restoration across all supported browsers?
0 reputation · 04 Jul 2024, 22:38 UTC
Background
The htmx SSE extension maintains persistent server-sent event connections for real-time updates, but its reconnection behavior after browser tab restoration or network interruption relies on the browser's native EventSource implementation combined with htmx's reconnect configuration parameter. The core documentation does not formally specify reconnection semantics, leaving developers uncertain about cross-browser consistency.
Goal
Determine whether the SSE extension provides a reliable, predictable reconnection guarantee when a backgrounded tab is restored or after transient network loss, without requiring custom heartbeat or fallback logic.
Constraints and uncertainty
Reconnection depends on EventSource behavior, which varies across browser engines (Chrome, Firefox, Safari). The reconnect parameter accepts a millisecond value but its interaction with browser-level EventSource retry logic is not documented. Version-sensitive changes in htmx v1.9 may have altered internal handling without updated guidance.
What is the expected reconnection sequence when a tab wakes from the back-forward cache? Does the reconnect parameter override or supplement the browser's native retry interval? Which browser versions have been validated for consistent SSE restoration behavior?