y-websocket
y-websocket copied to clipboard
Add a timeout status event
- A new status event: 'timeout' is fired when there has been inactivity on the websocket for a while and the websocket is marked for closing
- This is really handy with detecting network disconnection, because in that case the websocket does not really fire the 'close' event until the browser has finished the closing handshake.
- Added documentation for this
Is it possible to merge this? I use tldraw with y-websocket and observe weird behavior of all whiteboard to refresh and lose ability to react to hotkeys. Took me a few days to dig in and find the reason of y-websocket auto-close on inactivity. Now server cannot distinguish it from document delete-related socket closure. Additional timeout status would save several hours of debug.
The idea of the status event is to tell the user about the connection status. Hence, I'd prefer to add a status event { status: 'disconnecting', reason: 'timeout' | 'manual' }.