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

Broken socket reconnection on browser forward/back navigation #6103

Open
mateusz-slab opened this issue Feb 20, 2025 · 0 comments
Open

Broken socket reconnection on browser forward/back navigation #6103

mateusz-slab opened this issue Feb 20, 2025 · 0 comments

Comments

@mateusz-slab
Copy link

Environment

  • Elixir version: Elixir 1.18.2 (compiled with Erlang/OTP 27)
  • Phoenix version: phoenix 1.7.17
  • Operating system: MacOS X, Chrome

Actual behavior

We observe that the phoenix websocket connection is not re-established on forward/back navigation in user browser. While there's logic related to forward/back navigation in javascript client it seems to work incorrectly.

The pageshow event handler calls this.connect() that returns early if there's an active connection - if(this.conn){ return }.
The pagehide event is supposed to clear the this.conn field by calling this.disconnect() that calls this.teardown. Unfortunately, the code that actually clears the this.conn field is executed asynchronously. As user has already navigated out of the page the the code is not executed before pageshow event.

The behavior probably vary between browsers. I've tested on Chrome 133.0.6943.55.

Expected behavior

After forward/back navigation in user browser the websocket connection should be established.

@mateusz-slab mateusz-slab changed the title Broken reconnection on browser forward/back navigation Broken socket reconnection on browser forward/back navigation Feb 20, 2025
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

No branches or pull requests

1 participant