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

FR: WebSockets left open on pagehide prevent use of back/forward cache on Chrome #8845

Open
cjung89 opened this issue Mar 17, 2025 · 1 comment

Comments

@cjung89
Copy link

cjung89 commented Mar 17, 2025

Operating System

macOS 15.3.1

Environment (if applicable)

Chrome 134.0.6998.89

Firebase SDK Version

v4.12.1

Firebase SDK Product(s)

Database

Project Tooling

Unknown/ N/A as this is being detected from end-user side

Detailed Problem Description

Database SDK's WebSocket connection doesn't consistently close when a page becomes hidden (visibilitychange or pagehide), preventing Chrome from using Back/Forward Cache (bfcache). This forces full reloads, degrading the user experience.
To improve bfcache compatibility, the SDK could close the WebSocket connection within the pagehide event (or when visibilitychange state is hidden).
I'm not sure, but I think this could be addressed in PersistentConnection by modifying the onVisible_ to call close() when visibility becomes hidden, and ensuring shouldReconnect_ prevents immediate reconnection when the page is not visible.

Steps and code to reproduce issue

  1. Navigate to https://www.aajtak.in/ and wait for page to load
  2. In Application tab, select Back/forward cache and then select "Test back/forward cache"
Image
@cjung89 cjung89 added new A new issue that hasn't be categoirzed as question, bug or feature request question labels Mar 17, 2025
@jbalidiong jbalidiong added api: database and removed question new A new issue that hasn't be categoirzed as question, bug or feature request labels Mar 17, 2025
@hadyan
Copy link

hadyan commented Mar 19, 2025

+1 noticed a number of other sites that can benefit from bfcache if this is resolved. Thanks @cjung89.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants