-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Fix: Prevent 'can't find the internet' flash on reload (Firefox) #5735
base: main
Are you sure you want to change the base?
Fix: Prevent 'can't find the internet' flash on reload (Firefox) #5735
Conversation
I didn't dig very deep, so I just put this as a question here: could this have any effects for servers sending 1001, e.g. when caddy reloads its config? |
@ftes should it also include 1000 which would be normal close on page reload or navigate ? https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent/code |
I haven't observed errors for close code |
FWIW I've had to override it in my LV app with 1000 to stop seeing the connection lost alerts on firefox
|
Extra closeCodes handling for Firefox see phoenixframework/phoenix#5735 (comment)
Extra closeCodes handling for Firefox see phoenixframework/phoenix#5735 (comment)
Extra closeCodes handling for Firefox see phoenixframework/phoenix#5735 (comment)
Extra closeCodes handling for Firefox see phoenixframework/phoenix#5735 (comment)
Extra closeCodes handling for Firefox see phoenixframework/phoenix#5735 (comment)
Extra closeCodes handling for Firefox see phoenixframework/phoenix#5735 (comment)
Extra closeCodes handling for Firefox see phoenixframework/phoenix#5735 (comment)
See https://elixirforum.com/t/delaying-liveview-js-commands-avoid-quick-flash-of-trying-to-reconnect/64035. Relates to: phoenixframework/phoenix#5735 Maybe we need to tweak the timeout or make it configurable?
See https://elixirforum.com/t/delaying-liveview-js-commands-avoid-quick-flash-of-trying-to-reconnect/64035. Relates to: phoenixframework/phoenix#5735 Maybe we need to tweak the timeout or make it configurable?
Note: This bug is
LiveView
-specific. However, it seems necessary to apply the fix inphoenix
.On page reloads and browser back navigation I and others see the
phx-disconnected
flash error briefly pop up in Firefox.This change fixes the problem. It might not be a good fix, I'm unsure if there are other adverse effects.
It relies on the error code
1001
to detect this special situation in firefox, similar to this removed code in LiveVIew.Chain of events in Firefox:
phoenix/socket.js -> onConnClose
phoenix/socket.js -> triggerChanError -> channel.trigger('phx_error')
Note the diff between the logs (obtained via
new LiveSocket(... { logger: console.log })
:Firefox logs
transport close
,close { code: 1001 }
,channel error
where chrome doesn't.console log (firefox)
console log (chrome)
See
disconnected
event is triggered)