Handle null ref, when refresh conversation from db in websocket chat

This commit is contained in:
Debanjum Singh Solanky 2024-04-30 14:17:52 +05:30
parent 37879a7850
commit 9e068fad4f

View file

@ -338,7 +338,8 @@ async def websocket_endpoint(
await websocket.accept()
while connection_alive:
try:
await sync_to_async(conversation.refresh_from_db)(fields=["conversation_log"])
if conversation:
await sync_to_async(conversation.refresh_from_db)(fields=["conversation_log"])
q = await websocket.receive_text()
except WebSocketDisconnect:
logger.debug(f"User {user} disconnected web socket")