Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REF-3079] state.js: disconnect websocket for window "pagehide" event #3540

Merged
merged 1 commit into from
Jun 21, 2024

Conversation

masenf
Copy link
Collaborator

@masenf masenf commented Jun 21, 2024

All major browser use a "bfcache" to freeze pages when navigating away from the domain, then they restore the page when going back.

However if the page uses websockets, these get kind of stuck unless you disconnect them before freezing (and have a mechanism for reconnecting, which we already do).

Ref: https://web.dev/articles/bfcache

Fix #3478

All major browser use a "bfcache" to freeze pages when navigating away from the
domain, then they restore the page when going back.

However if the page uses websockets, these get kind of stuck unless you
disconnect them before freezing (and have a mechanism for reconnecting, which
we already do).

Ref: https://web.dev/articles/bfcache

Fix #3478
Copy link

linear bot commented Jun 21, 2024

Copy link
Contributor

@picklelo picklelo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interesting, didn't know about bfcache

@masenf
Copy link
Collaborator Author

masenf commented Jun 21, 2024

didn't know about bfcache

Me either, but Chrome at least logs a message on the browser console with a link to the page above that explains it in pretty good detail, so that was a nice hint.

I wish i knew why it didn't work in dev mode though... maybe dev mode has an unload event listener?

On desktop, Chrome and Firefox have chosen to make pages ineligible for bfcache if they add an unload listener, which is less risky but also disqualifies a lot of pages. Safari will attempt to cache some pages with an unload event listener, but to reduce potential breakage it won't run the unload event when a user is navigating away, which makes the event very unreliable. [1]

@Lendemor Lendemor merged commit 1a74ff4 into main Jun 21, 2024
47 checks passed
@masenf masenf deleted the masenf/bfcache branch June 25, 2024 02:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[REF-3079] State hangs after using back button after following a link.
3 participants