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

Refresh page when websocket is closed but user has interacted with page #8155

Closed
wants to merge 2 commits into from

Conversation

NickM-27
Copy link
Sponsor Collaborator

fixes #5000

@netlify
Copy link

netlify bot commented Oct 13, 2023

Deploy Preview for frigate-docs canceled.

Name Link
🔨 Latest commit e869917
🔍 Latest deploy log https://app.netlify.com/sites/frigate-docs/deploys/6529a7f1392b9a0008496bbf

// if ws is closed but user has interacted with page
// refresh to ensure state is up to date
if (ws.readyState == WebSocket.CLOSED) {
location.reload();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there not a way to try reconnecting the websocket without a refresh?

Copy link
Sponsor Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't figure out how to do that because ws object does not have that function directly and the send function doesn't have access to the fields necessary to rebuild the ws object.

I believe refreshing may provide some utility in the case that frigate has stopped but the user tries to interact with the webUI.

That being said, I believe @hawkeye217 may have a better way to fix this

Copy link
Collaborator

@hawkeye217 hawkeye217 Oct 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've used react-use-websocket before, it's pretty simple and robust. But I'm not sure it has preact compatibility (we're running 17.1.2 and the latest version needs react >= 18) so unless we want to go down the react-compat route, my fix may not be as straightforward as I would have hoped. I'll try an older version and see what happens.

@NickM-27
Copy link
Sponsor Collaborator Author

will be replaced by separate PR

@NickM-27 NickM-27 closed this Oct 14, 2023
@NickM-27 NickM-27 deleted the dead-ws-refresh branch October 14, 2023 12:49
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

Successfully merging this pull request may close these issues.

[Support]: Main page loses WS connection, toggle buttons silently fail
3 participants