Open tbronson opened 1 month ago
Thanks for the report @tbronson. Could you when exactly this happens? If a client drops the connection without properly closing it?
Yes, specifically I found this while testing Panel 1.5.0rc2 on Windows 10.
Launch any panel app with 'admin=True', open the admin panel in a tab, then close the tab and check server console. It will be spammed with unhandled write exceptions to closed websocket (from periodic_callbacks) and the sessions will never be cleaned up either.
I should clarify:
The websocket.disconnect message does come in, it's just not handled completely, hence the _raise_on_disconnect call
Handling of detecting when the websockets close is bugged at the moment, sessions are never cleaned up because of it.
Here are a couple patches that fix the issue:
handler.py
receive does not raise when the socket is closed normally, but starlette has a private helper function to do so
send_text and send_bytes do raise, they just needed to be put in a try block