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

Force page reload on socket connect error 'parser error' #962

Merged
merged 6 commits into from
Jun 12, 2024

Conversation

colinl
Copy link
Contributor

@colinl colinl commented Jun 12, 2024

Description

If there is a proxy server which requires a user login if the authorisation token expires, and the dashboard socket is already connected at this time, then the dashboard continues as normal, presumably because the connection is already open. If, however, the connection is dropped then the reconnect attempt fails as the request is forwarded to the login page. The result is that there is a connect error and the returned error object contains just {"code":"parser error"}. This is a permanent error, so retrying the connection is pointless.
This PR recognises that code and forces a page reload, so that the user is directed to the login page.

There may be other reasons for a 'parser error', but whatever the reason there is little that we can do other than force a reload.

See discussions in #946, which this PR closes

Related Issue(s)

See discussions in #946, which this PR closes.

Checklist

  • [ x] I have read the contribution guidelines
  • Suitable unit/system level tests have been added and they pass
  • Documentation has been updated
    • Upgrade instructions
    • Configuration details
    • Concepts
  • Changes flowforge.yml?
    • Issue/PR raised on FlowFuse/helm to update ConfigMap Template
    • Issue/PR raised on FlowFuse/CloudProject to update values for Staging/Production

Labels

  • Includes a DB migration? -> add the area:migration label

@joepavitt joepavitt requested a review from cstns June 12, 2024 09:24
ui/src/main.mjs Outdated
@@ -151,6 +151,14 @@ fetch('_setup')

socket.on('connect_error', (err) => {
console.error('SIO connect error:', err, `err: ${JSON.stringify(err)}`)
if (err?.code === "parser error") {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (err?.code === "parser error") {
if (err?.code === 'parser error') {

Copy link
Contributor

Choose a reason for hiding this comment

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

Fixes linting errors

ui/src/main.mjs Outdated Show resolved Hide resolved
@colinl
Copy link
Contributor Author

colinl commented Jun 12, 2024

I had already fixed the linting errors.

@cstns cstns merged commit a57d4b0 into FlowFuse:main Jun 12, 2024
2 checks passed
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.

2 participants