fix(clustermap): stop EventSource reload from hijacking navigation in Firefox#24
Merged
FreekBes merged 1 commit intoJun 9, 2026
Conversation
… Firefox The live clustermap's EventSource error handler called window.location.reload() unconditionally. In Firefox, navigating away (or clicking external links such as CONTRIBUTE) tears down the SSE connection during page unload and dispatches an 'error' event, so the handler reloaded the page and cancelled the navigation, snapping the user back to the clustermap. Guard the reload with a pagehide/beforeunload flag so it never fights the browser's own navigation, and only reload on a permanent failure (readyState === CLOSED) instead of on every transient error, letting EventSource perform its normal automatic reconnection.
|
🎉 This PR is included in version 2.3.2 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On Firefox, while on the live clustermap page, navigating away is broken:
nu.nl) and pressing enter snaps back to the clustermap instead of navigating.This does not reproduce on Chromium-based browsers.
Cause
static/js/clustermaps/live.jsopens a Server-Sent Events stream (EventSource) and itserrorhandler callswindow.location.reload()unconditionally.When the page starts unloading during navigation, Firefox tears down the SSE connection and dispatches an
errorevent. The handler then reloads the page, cancelling the in-progress navigation and returning the user to the clustermap. Chromium does not dispatch this error during unload, so the bug is Firefox-only.Fix
pagehide/beforeunloadflag (isUnloading) so the reload never fights the browser's own navigation.readyState === EventSource.CLOSED) instead of on every transienterror, lettingEventSourceperform its normal automatic reconnection.closehandler.Testing
/clustermap/live, navigate to an external URL and click the CONTRIBUTE link — both now work as expected.