Improved WebSocket Error Handling (#8924)

Co-authored-by: openhands <openhands@all-hands.dev>
This commit is contained in:
tofarr
2025-06-05 16:42:18 -06:00
committed by GitHub
parent 336b22bea4
commit 19fcf427ba
10 changed files with 87 additions and 12 deletions

View File

@@ -281,7 +281,23 @@ class DockerNestedConversationManager(ConversationManager):
raise ValueError('unsupported_operation')
async def close_session(self, sid: str):
stop_all_containers(f'openhands-runtime-{sid}')
# First try to graceful stop server.
try:
container = self.docker_client.containers.get(f'openhands-runtime-{sid}')
except docker.errors.NotFound as e:
return
try:
nested_url = self.get_nested_url_for_container(container)
async with httpx.AsyncClient(
headers={
'X-Session-API-Key': self._get_session_api_key_for_conversation(sid)
}
) as client:
response = await client.post(f'{nested_url}/api/conversations/{sid}/stop')
response.raise_for_status()
except Exception:
logger.exception("error_stopping_container")
container.stop()
async def get_agent_loop_info(self, user_id: str | None = None, filter_to_sids: set[str] | None = None) -> list[AgentLoopInfo]:
results = []