diff --git a/pycrdt_websocket/yroom.py b/pycrdt_websocket/yroom.py index 6a9c2ec..d1f77de 100644 --- a/pycrdt_websocket/yroom.py +++ b/pycrdt_websocket/yroom.py @@ -309,10 +309,11 @@ async def serve(self, websocket: Websocket): tg.start_soon(client.send, message) # apply awareness update to the server's awareness self.awareness.apply_awareness_update(read_message(message[1:]), self) - # remove this client - self.clients.remove(websocket) except Exception as exception: self._handle_exception(exception) + finally: + # remove this client + self.clients.remove(websocket) def send_server_awareness(self, type: str, changes: tuple[dict[str, Any], Any]) -> None: """