From ef6fdad13cb59053079c919f2621347ff5eec3ca Mon Sep 17 00:00:00 2001 From: yugalkaushik Date: Fri, 26 Dec 2025 16:42:11 +0000 Subject: [PATCH] fix error --- Backend/app/routes/chat.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Backend/app/routes/chat.py b/Backend/app/routes/chat.py index f51d6b7..2a892a1 100644 --- a/Backend/app/routes/chat.py +++ b/Backend/app/routes/chat.py @@ -42,10 +42,18 @@ async def websocket_endpoint( except WebSocketDisconnect: listener_task.cancel() + try: + await listener_task + except asyncio.CancelledError: + pass await chat_service.disconnect(user_id, redis, db) except Exception as e: listener_task.cancel() + try: + await listener_task + except asyncio.CancelledError: + pass await chat_service.disconnect(user_id, redis, db) # Optionally log the error print(f"Error in websocket for user {user_id}: {e}")