Fix: Prevent 'can't find the internet' flash on reload (Firefox) #5735
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.
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)