When a browser or tab is closed, I have a small snippet that sends an XHttpRequest to a given endpoint to signal that the WebSocket connection has been dropped abnormally.
wsConnection.onclose = function(event) {
axios.post('/state', { reason: 'abnormal' });
};
Is there a guarantee that the browser will execute the event on a tab/window close? If not, then how do I detect the "client disconnected forcefully"?