From 6b6ac171675627729586dd6049af7b05f4c2581e Mon Sep 17 00:00:00 2001 From: Gabriel Almeida Date: Wed, 10 May 2023 12:09:14 -0300 Subject: [PATCH] fix(chat_manager.py): close websocket connection with status code 1011 and error message on exception --- src/backend/langflow/api/chat_manager.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/backend/langflow/api/chat_manager.py b/src/backend/langflow/api/chat_manager.py index 7ada67793..1d5cc2406 100644 --- a/src/backend/langflow/api/chat_manager.py +++ b/src/backend/langflow/api/chat_manager.py @@ -3,7 +3,7 @@ import json from collections import defaultdict from typing import Dict, List -from fastapi import WebSocket +from fastapi import WebSocket, status from langflow.api.schemas import ChatMessage, ChatResponse, FileResponse from langflow.cache import cache_manager @@ -176,7 +176,9 @@ class ChatManager: # Handle any exceptions that might occur logger.exception(e) # send a message to the client - raise e + await self.active_connections[client_id].close( + code=status.WS_1011_INTERNAL_ERROR, reason=str(e) + ) finally: try: await self.active_connections[client_id].close(