canonical / maas-ui

The UI for MAAS (metal-as-a-service)
https://maas.io
Other
52 stars 51 forks source link

WebSocket connection is closed abnormally #3930

Open petermakowski opened 2 years ago

petermakowski commented 2 years ago

Steps to reproduce

  1. Open network inspector (e.g. via Firefox Developer Tools)
  2. Go to maas-ui and login
  3. Click log out
  4. Inspect WebSocket connection

Actual

On logout, we're closing a WebSocket connection abnormally with an incorrect status: 1006 Abnormal Closure We seem to be relying on page reload to destroy the websocket connection instead of closing it manually : https://github.com/canonical/maas-ui/blob/06a9d480f422a174a7bdfac3f6c89ecab04b827b/ui/src/app/base/sagas/http.ts#L138-L145

Expected

On logout, we're closing a WebSocket connection normally with a status code of 1000 Normal Closure - The connection successfully completed the purpose for which it was created. CloseEvent.code - Web APIs | MDN RFC 6455: The WebSocket Protocol before/without reloading the page.


May be related: https://github.com/canonical-web-and-design/maas-ui/issues/864

sparkiegeek commented 1 year ago

more specifically https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API/Writing_WebSocket_client_applications#closing_the_connection