diff --git a/src/backend/base/langflow/api/v1/chat.py b/src/backend/base/langflow/api/v1/chat.py index 00afd0d7d78..1af57a06165 100644 --- a/src/backend/base/langflow/api/v1/chat.py +++ b/src/backend/base/langflow/api/v1/chat.py @@ -448,7 +448,9 @@ async def listen_for_disconnect(self, receive: Receive) -> None: message = await receive() if message["type"] == "http.disconnect": if self.on_disconnect: - await self.on_disconnect() + coro = self.on_disconnect() + if asyncio.iscoroutine(coro): + await coro break