From 628865fd0644cc7741e1918f6259bd4611958a71 Mon Sep 17 00:00:00 2001 From: Junyan Qin Date: Tue, 23 Dec 2025 14:17:16 +0800 Subject: [PATCH] fix: add timeout to image fetching in get_qq_image_bytes function (#1859) --- src/langbot/pkg/utils/image.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/langbot/pkg/utils/image.py b/src/langbot/pkg/utils/image.py index d9518e12..e07caec6 100644 --- a/src/langbot/pkg/utils/image.py +++ b/src/langbot/pkg/utils/image.py @@ -153,7 +153,9 @@ async def get_qq_image_bytes(image_url: str, query: dict = {}) -> tuple[bytes, s ssl_context.check_hostname = False ssl_context.verify_mode = ssl.CERT_NONE async with aiohttp.ClientSession(trust_env=False) as session: - async with session.get(image_url, params=query, ssl=ssl_context) as resp: + async with session.get( + image_url, params=query, ssl=ssl_context, timeout=aiohttp.ClientTimeout(total=30.0) + ) as resp: resp.raise_for_status() file_bytes = await resp.read() content_type = resp.headers.get('Content-Type')