From 387d57b3e51aad0881c899b902324b9edc55ece1 Mon Sep 17 00:00:00 2001 From: Yemre Cakiroglu Date: Thu, 12 Mar 2026 14:23:30 +0100 Subject: [PATCH] fix: ssl negotiation unhandled exception --- asyncpg/connect_utils.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/asyncpg/connect_utils.py b/asyncpg/connect_utils.py index 07c4fdde..bf6ebc0d 100644 --- a/asyncpg/connect_utils.py +++ b/asyncpg/connect_utils.py @@ -944,7 +944,10 @@ def data_received(self, data: bytes) -> None: def connection_lost(self, exc: typing.Optional[Exception]) -> None: if not self.on_data.done(): if exc is None: - exc = ConnectionError('unexpected connection_lost() call') + exc = ConnectionResetError( + 'PostgreSQL server at "{host}:{port}" ' + 'closed the connection during SSL negotiation'.format( + host=self.host, port=self.port)) self.on_data.set_exception(exc)