Downgrade ConnectionClosedOK from ERROR to INFO level (#4541)

This commit is contained in:
pedrohsdb
2026-01-23 16:19:58 -08:00
committed by GitHub
parent 43d8020792
commit b44c0ac3df
2 changed files with 26 additions and 4 deletions

View File

@@ -26,7 +26,7 @@ import structlog
import websockets import websockets
from fastapi import WebSocket, WebSocketDisconnect from fastapi import WebSocket, WebSocketDisconnect
from starlette.websockets import WebSocketState from starlette.websockets import WebSocketState
from websockets import ConnectionClosedError, Data from websockets import ConnectionClosedError, ConnectionClosedOK, Data
from skyvern.config import settings from skyvern.config import settings
from skyvern.forge.sdk.routes.streaming.auth import get_x_api_key from skyvern.forge.sdk.routes.streaming.auth import get_x_api_key
@@ -253,7 +253,7 @@ async def copy_text(vnc_channel: VncChannel) -> None:
if message_channel: if message_channel:
await message_channel.send_copied_text(copied_text) await message_channel.send_copied_text(copied_text)
else: else:
LOG.warning( LOG.info(
f"{class_name} No message channel found for client, or it is not open", f"{class_name} No message channel found for client, or it is not open",
message_channel=message_channel, message_channel=message_channel,
**vnc_channel.identity, **vnc_channel.identity,
@@ -272,7 +272,7 @@ async def ask_for_clipboard(vnc_channel: VncChannel) -> None:
if message_channel: if message_channel:
await message_channel.ask_for_clipboard() await message_channel.ask_for_clipboard()
else: else:
LOG.warning( LOG.info(
f"{class_name} No message channel found for client, or it is not open", f"{class_name} No message channel found for client, or it is not open",
message_channel=message_channel, message_channel=message_channel,
**vnc_channel.identity, **vnc_channel.identity,
@@ -408,6 +408,9 @@ async def loop_stream_vnc(vnc_channel: VncChannel) -> None:
except ConnectionClosedError: except ConnectionClosedError:
LOG.info(f"{class_name} Frontend closed the vnc channel.", **vnc_channel.identity) LOG.info(f"{class_name} Frontend closed the vnc channel.", **vnc_channel.identity)
raise raise
except ConnectionClosedOK:
LOG.info(f"{class_name} Frontend closed the vnc channel cleanly.", **vnc_channel.identity)
raise
except asyncio.CancelledError: except asyncio.CancelledError:
pass pass
except Exception: except Exception:
@@ -425,6 +428,9 @@ async def loop_stream_vnc(vnc_channel: VncChannel) -> None:
except ConnectionClosedError: except ConnectionClosedError:
LOG.info(f"{class_name} Browser closed vnc.", **vnc_channel.identity) LOG.info(f"{class_name} Browser closed vnc.", **vnc_channel.identity)
raise raise
except ConnectionClosedOK:
LOG.info(f"{class_name} Browser closed vnc cleanly.", **vnc_channel.identity)
raise
except asyncio.CancelledError: except asyncio.CancelledError:
pass pass
except Exception: except Exception:
@@ -450,6 +456,9 @@ async def loop_stream_vnc(vnc_channel: VncChannel) -> None:
except ConnectionClosedError: except ConnectionClosedError:
LOG.info(f"{class_name} Browser closed the vnc channel session.", **vnc_channel.identity) LOG.info(f"{class_name} Browser closed the vnc channel session.", **vnc_channel.identity)
await vnc_channel.close(reason="browser-closed") await vnc_channel.close(reason="browser-closed")
except ConnectionClosedOK:
LOG.info(f"{class_name} Browser closed the vnc channel session cleanly.", **vnc_channel.identity)
await vnc_channel.close(reason="browser-closed-ok")
except asyncio.CancelledError: except asyncio.CancelledError:
pass pass
except Exception: except Exception:
@@ -474,6 +483,9 @@ async def loop_stream_vnc(vnc_channel: VncChannel) -> None:
except ConnectionClosedError: except ConnectionClosedError:
LOG.info(f"{class_name} Frontend closed the vnc channel session.", **vnc_channel.identity) LOG.info(f"{class_name} Frontend closed the vnc channel session.", **vnc_channel.identity)
await vnc_channel.close(reason="frontend-closed") await vnc_channel.close(reason="frontend-closed")
except ConnectionClosedOK:
LOG.info(f"{class_name} Frontend closed the vnc channel session cleanly.", **vnc_channel.identity)
await vnc_channel.close(reason="frontend-closed-ok")
except asyncio.CancelledError: except asyncio.CancelledError:
pass pass
except Exception: except Exception:
@@ -489,6 +501,8 @@ async def loop_stream_vnc(vnc_channel: VncChannel) -> None:
await collect(loops) await collect(loops)
except WebSocketDisconnect: except WebSocketDisconnect:
pass pass
except ConnectionClosedOK:
LOG.info(f"{class_name} Connection closed cleanly in loop stream.", **vnc_channel.identity)
except Exception: except Exception:
LOG.exception(f"{class_name} An exception occurred in loop stream.", **vnc_channel.identity) LOG.exception(f"{class_name} An exception occurred in loop stream.", **vnc_channel.identity)
finally: finally:

View File

@@ -11,6 +11,7 @@ NOTE(jdo:streaming-local-dev)
import structlog import structlog
from fastapi import WebSocket from fastapi import WebSocket
from websockets.exceptions import ConnectionClosedOK
from skyvern.config import settings from skyvern.config import settings
from skyvern.forge.sdk.routes.routers import base_router, legacy_base_router from skyvern.forge.sdk.routes.routers import base_router, legacy_base_router
@@ -92,7 +93,7 @@ async def stream(
organization_id = await auth(apikey=apikey, token=token, websocket=websocket) organization_id = await auth(apikey=apikey, token=token, websocket=websocket)
if not organization_id: if not organization_id:
LOG.warning("Authentication failed.", task_id=task_id, workflow_run_id=workflow_run_id) LOG.info("Authentication failed.", task_id=task_id, workflow_run_id=workflow_run_id)
return return
vnc_channel: VncChannel vnc_channel: VncChannel
@@ -166,6 +167,13 @@ async def stream(
organization_id=organization_id, organization_id=organization_id,
) )
await collect(loops) await collect(loops)
except ConnectionClosedOK:
LOG.info(
"VNC connection closed cleanly.",
task_id=task_id,
workflow_run_id=workflow_run_id,
organization_id=organization_id,
)
except Exception: except Exception:
LOG.exception( LOG.exception(
"An exception occurred in the vnc loop.", "An exception occurred in the vnc loop.",