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
8 changes: 8 additions & 0 deletions ui/src/main.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
// There has been a 'parser error' during the attempt to connect. This means that socket.io
// does not like the response from the server from the attempt to connect.
// This happens if there is a proxy server in front of node red that has redirected to
// a login page. There may also be other situations under which this error occurs, but whatever the
// cause it doesn't seem that we can do much other than force a reload.
forcePageReload('parser error')
}
})

// default interval - every 2.5 seconds
Expand Down