From e9b44ac781a54a8cb9fc34f35cc6bf40009117f3 Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Fri, 30 Jun 2023 16:42:33 -0300 Subject: [PATCH] fix(chat.py): add comment explaining the behavior of accepting and immediately closing the connection if the flow is not built yet --- src/backend/langflow/api/v1/chat.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/backend/langflow/api/v1/chat.py b/src/backend/langflow/api/v1/chat.py index 500e1d0bc..bf1b52058 100644 --- a/src/backend/langflow/api/v1/chat.py +++ b/src/backend/langflow/api/v1/chat.py @@ -19,6 +19,8 @@ async def chat(client_id: str, websocket: WebSocket): if client_id in chat_manager.in_memory_cache: await chat_manager.handle_websocket(client_id, websocket) else: + # We accept the connection but close it immediately + # if the flow is not built yet await websocket.accept() message = "Please, build the flow before sending messages" await websocket.close(code=status.WS_1011_INTERNAL_ERROR, reason=message)