From 9989e579da217f0c1d75c132d3a752ddb9973bea Mon Sep 17 00:00:00 2001 From: "memosr.eth" <96793918+memosr@users.noreply.github.com> Date: Thu, 26 Mar 2026 11:58:11 +0300 Subject: [PATCH] fix: add request timeouts to send_message_tool HTTP calls (#3162) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit _send_discord(), _send_slack(), and _send_twilio() all created aiohttp.ClientSession() without a timeout, leaving HTTP requests able to hang indefinitely. _send_whatsapp() already used aiohttp.ClientTimeout(total=30) — this fix applies the same pattern consistently to all platform send functions. - Add ClientTimeout(total=30) to _send_discord() ClientSession - Add ClientTimeout(total=30) to _send_slack() ClientSession - Add ClientTimeout(total=30) to _send_twilio() ClientSession --- tools/send_message_tool.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/send_message_tool.py b/tools/send_message_tool.py index b4748a486..cf983445b 100644 --- a/tools/send_message_tool.py +++ b/tools/send_message_tool.py @@ -490,7 +490,7 @@ async def _send_discord(token, chat_id, message): try: url = f"https://discord.com/api/v10/channels/{chat_id}/messages" headers = {"Authorization": f"Bot {token}", "Content-Type": "application/json"} - async with aiohttp.ClientSession() as session: + async with aiohttp.ClientSession(timeout=aiohttp.ClientTimeout(total=30)) as session: async with session.post(url, headers=headers, json={"content": message}) as resp: if resp.status not in (200, 201): body = await resp.text() @@ -510,7 +510,7 @@ async def _send_slack(token, chat_id, message): try: url = "https://slack.com/api/chat.postMessage" headers = {"Authorization": f"Bearer {token}", "Content-Type": "application/json"} - async with aiohttp.ClientSession() as session: + async with aiohttp.ClientSession(timeout=aiohttp.ClientTimeout(total=30)) as session: async with session.post(url, headers=headers, json={"channel": chat_id, "text": message}) as resp: data = await resp.json() if data.get("ok"): @@ -649,7 +649,7 @@ async def _send_sms(auth_token, chat_id, message): url = f"https://api.twilio.com/2010-04-01/Accounts/{account_sid}/Messages.json" headers = {"Authorization": f"Basic {encoded}"} - async with aiohttp.ClientSession() as session: + async with aiohttp.ClientSession(timeout=aiohttp.ClientTimeout(total=30)) as session: form_data = aiohttp.FormData() form_data.add_field("From", from_number) form_data.add_field("To", chat_id)