fix: ensure socket cleanup in websocket handler

This commit is contained in:
retoor 2025-12-17 22:54:25 +01:00
parent bdc8f149dc
commit 70a405b231
3 changed files with 25 additions and 14 deletions

View File

@ -7,6 +7,14 @@
## Version 1.7.0 - 2025-12-17
Fixes socket cleanup in the websocket handler to prevent resource leaks and improve connection stability.
**Changes:** 1 files, 29 lines
**Languages:** Python (29 lines)
## Version 1.6.0 - 2025-12-17 ## Version 1.6.0 - 2025-12-17
Removes presence debounce to make user departures instant. Simplifies websocket connection and error handling in RPC views for improved reliability. Removes presence debounce to make user departures instant. Simplifies websocket connection and error handling in RPC views for improved reliability.

View File

@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
[project] [project]
name = "Snek" name = "Snek"
version = "1.6.0" version = "1.7.0"
readme = "README.md" readme = "README.md"
#license = { file = "LICENSE", content-type="text/markdown" } #license = { file = "LICENSE", content-type="text/markdown" }
description = "Snek Chat Application by Molodetz" description = "Snek Chat Application by Molodetz"

View File

@ -650,17 +650,20 @@ class RPCView(BaseView):
) )
rpc = RPCView.RPCApi(self, ws) rpc = RPCView.RPCApi(self, ws)
async for msg in ws: try:
if msg.type == web.WSMsgType.TEXT: async for msg in ws:
try: if msg.type == web.WSMsgType.TEXT:
await rpc(msg.json()) try:
except Exception as ex: await rpc(msg.json())
print("XXXXXXXXXX Deleting socket", ex, flush=True) except Exception as ex:
logger.exception(ex) print("XXXXXXXXXX Deleting socket", ex, flush=True)
await self.services.socket.delete(ws) logger.exception(ex)
break await self.services.socket.delete(ws)
elif msg.type == web.WSMsgType.ERROR: break
pass elif msg.type == web.WSMsgType.ERROR:
elif msg.type == web.WSMsgType.CLOSE: pass
pass elif msg.type == web.WSMsgType.CLOSE:
pass
finally:
await self.services.socket.delete(ws)
return ws return ws