Skip to content

Automate browser based workflows with AI

Warn ConnectionClosedError in websocket/streaming (#3760)

Stanislav Novosad441f46ab5ce3
diff --git a/skyvern/forge/sdk/routes/streaming.py b/skyvern/forge/sdk/routes/streaming.py
index 302ff5c33..76a576ef4 100644
--- a/skyvern/forge/sdk/routes/streaming.py
+++ b/skyvern/forge/sdk/routes/streaming.py
@@ -5,7 +5,7 @@ from datetime import datetime
import structlog
from fastapi import WebSocket, WebSocketDisconnect
from pydantic import ValidationError
-from websockets.exceptions import ConnectionClosedOK
+from websockets.exceptions import ConnectionClosedError, ConnectionClosedOK
from skyvern.forge import app
from skyvern.forge.sdk.routes.routers import legacy_base_router
@@ -112,6 +112,13 @@ async def task_stream(
except ConnectionClosedOK:
LOG.info("ConnectionClosedOK error while streaming", task_id=task_id, organization_id=organization_id)
return
+ except ConnectionClosedError:
+ LOG.warning(
+ "ConnectionClosedError while streaming (client likely disconnected)",
+ task_id=task_id,
+ organization_id=organization_id,
+ )
+ return
except Exception:
LOG.warning("Error while streaming", task_id=task_id, organization_id=organization_id, exc_info=True)
return
@@ -237,6 +244,13 @@ async def workflow_run_streaming(
organization_id=organization_id,
)
return
+ except ConnectionClosedError:
+ LOG.warning(
+ "WofklowRun Streaming: ConnectionClosedError while streaming (client likely disconnected)",
+ workflow_run_id=workflow_run_id,
+ organization_id=organization_id,
+ )
+ return
except Exception:
LOG.warning(
"WofklowRun Streaming: Error while streaming",