fix: close SSE connection cleanly on page navigation
beforeunload closes the EventSource explicitly so the browser doesn't log "connection interrupted while page was loading". onerror handler suppresses auto-reconnect noise if the connection temporarily drops. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1080,6 +1080,13 @@
|
||||
// ── Real-time Talk updates (SSE) ─────────────────────────────
|
||||
const evtSource = new EventSource('/events');
|
||||
|
||||
// Close cleanly on navigation so the browser doesn't log "connection interrupted"
|
||||
window.addEventListener('beforeunload', () => evtSource.close());
|
||||
|
||||
evtSource.onerror = () => {
|
||||
// EventSource auto-reconnects — nothing to do; suppress console noise
|
||||
};
|
||||
|
||||
evtSource.onmessage = (e) => {
|
||||
let data;
|
||||
try { data = JSON.parse(e.data); } catch { return; }
|
||||
|
||||
Reference in New Issue
Block a user