From edcb6bd14da0a6f3a1e6f3bba043181e9837d899 Mon Sep 17 00:00:00 2001 From: Ishaan Jaffer Date: Fri, 20 Feb 2026 17:21:47 -0800 Subject: [PATCH] fix(proxy): harden prisma reconnect cycle semantics --- litellm/proxy/utils.py | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/litellm/proxy/utils.py b/litellm/proxy/utils.py index d2b23cc99b3..4e51d58837d 100644 --- a/litellm/proxy/utils.py +++ b/litellm/proxy/utils.py @@ -3553,30 +3553,26 @@ class PrismaClient: ) -> None: """ Run a reconnect cycle. When timeout_seconds is set, use direct db operations - with per-step timeouts to avoid long retries on hot paths (e.g. auth). + with a single overall timeout budget to avoid long retries on hot paths + (e.g. auth). """ - if timeout_seconds is None: + async def _do_direct_reconnect() -> None: try: - await self.disconnect() + await self.db.disconnect() except Exception as disconnect_err: verbose_proxy_logger.debug( "Prisma DB disconnect before reconnect failed (ignored): %s", disconnect_err, ) - await self.connect() - await self.health_check() + + await self.db.connect() + await self.db.query_raw("SELECT 1") + + if timeout_seconds is None: + await _do_direct_reconnect() return - try: - await self.db.disconnect() - except Exception as disconnect_err: - verbose_proxy_logger.debug( - "Prisma DB disconnect before reconnect failed (ignored): %s", - disconnect_err, - ) - - await asyncio.wait_for(self.db.connect(), timeout=timeout_seconds) - await asyncio.wait_for(self.db.query_raw("SELECT 1"), timeout=timeout_seconds) + await asyncio.wait_for(_do_direct_reconnect(), timeout=timeout_seconds) async def attempt_db_reconnect( self,