Here is how the described reproduction steps produce a websocket connection that is opened and then immediately closed:
- Browser requests index.html and index.js because the URL is http://localhost:8090/#/reports. The hash portion of the url is not sent to the server so it does not know that this is a page the user has to be logged in for, so it can't answer with a redirect
- The frontend looks at the URL to determine what to render. #/reports renders the Reports list page and the footer
- The footer establishes a websocket connection
- At the same time, the report list tries to load the list of reports. The server realizes that the user is not logged in and responds with a redirect
- Due to the redirect, the newly established websocket connection of the footer is closed.
- Since the connection was previously opened the backend tries to send the initial status data over the websocket, but it was already closed
So it's kind of a race condition, but it appears to be very consistent. Ideally, when sending any data over the websocket we could check if it is still open.