From 1e41d5b9842db00ccc38dc7bc20163e0c38d1e6d Mon Sep 17 00:00:00 2001 From: hliu-roblox <87345548+hliu-roblox@users.noreply.github.com> Date: Tue, 10 Mar 2026 12:21:02 -0700 Subject: [PATCH] fix(logging): log ConnectError details before retry in http_handler ConnectError and RemoteProtocolError exceptions are silently caught and retried without any logging, making it impossible to diagnose connection failures in production. Add verbose_logger.warning() to emit the target URL and error details before the retry attempt. --- litellm/llms/custom_httpx/http_handler.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/litellm/llms/custom_httpx/http_handler.py b/litellm/llms/custom_httpx/http_handler.py index 3dfef07d426..859ea6d2b4d 100644 --- a/litellm/llms/custom_httpx/http_handler.py +++ b/litellm/llms/custom_httpx/http_handler.py @@ -466,7 +466,8 @@ class AsyncHTTPHandler: response = await self.client.send(req, stream=stream) response.raise_for_status() return response - except (httpx.RemoteProtocolError, httpx.ConnectError): + except (httpx.RemoteProtocolError, httpx.ConnectError) as e: + verbose_logger.warning(f"ConnectError on POST {url}: {e}") # Retry the request with a new session if there is a connection error new_client = self.create_client( timeout=timeout, event_hooks=self.event_hooks @@ -538,7 +539,8 @@ class AsyncHTTPHandler: response = await self.client.send(req) response.raise_for_status() return response - except (httpx.RemoteProtocolError, httpx.ConnectError): + except (httpx.RemoteProtocolError, httpx.ConnectError) as e: + verbose_logger.warning(f"ConnectError on PUT {url}: {e}") # Retry the request with a new session if there is a connection error new_client = self.create_client( timeout=timeout, event_hooks=self.event_hooks