fix(web): close the SSE EventSource on pagehide (BUNYIP-380) #377
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/BUNYIP-380-sse-pagehide-close"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Closes the injected
/v1/eventsEventSource onpagehideso server-rendered navigations no longer log the "connection was interrupted while the page was loading" console warning. Fixes BUNYIP-380.Root cause
bunyip-web is server-rendered: every in-app navigation is a full page load. The departing page's long-lived EventSource is aborted mid-flight by the browser as the next document loads, so the browser logs "The connection to .../v1/events was interrupted while the page was loading" on every navigation. Harmless (the next page opens a fresh stream) but it clutters the console and can mask real errors.
Change
bunyip-web/src/views/layout.rsSSE_SUBSCRIBER: addwindow.addEventListener('pagehide',function(){try{es.close();}catch(e){}});right after the EventSource is created, so the stream closes cleanly before the document unloads instead of being interrupted.es.close()is idempotent. No server change - the/v1/eventshandler is untouched - and CSP isscript-src 'self' 'unsafe-inline', so the inline-script edit needs no hash/nonce update.Scope note
The
content.js:138 the element does not existline reported alongside the warning is a browser extension content script, not bunyip - out of scope per the ticket.Test
just check-containergreen (fmt + clippy + 104 tests). After deploy, verify in-app navigation no longer logs the/v1/eventsinterrupted warning and that SSE still connects and delivers per-user events (BUNYIP-145 behaviour intact - the change only adds a close-on-unload).