-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Firefox infinitely reloads the page as long as `<LiveReload>` is rendering. Closes #4692
- Loading branch information
1 parent
3d81516
commit db88c96
Showing
2 changed files
with
25 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
"@remix-run/react": patch | ||
--- | ||
|
||
Fixed a problem with live reload and firefox infinitely reloading the page | ||
|
||
The problem is: | ||
|
||
1. Firefox is calling `ws.onclose` immediately upon connecting (?!) | ||
2. Then we’re trying to reconnect, and upon reconnection, we reload the page. | ||
3. Firefox then calls `ws.onclose` again after reconnecting and the loop starts over | ||
|
||
This fix is to check `event.code === 1006` before actually trying to reconnect and the reload the page. 1006 means the connection was closed abnormally (https://www.rfc-editor.org/rfc/rfc6455#section-7.4.1). In our case, that means the server was shut down in local dev and then the socket can reconnect again when the server is back up. | ||
|
||
It’s unclear to me why Firefox is calling `onclose` immediately upon connecting to the web socket, but it does. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters