From 4303026e0da53c5f0b819df33bf91adda8aa3ba5 Mon Sep 17 00:00:00 2001 From: Nikolas de Hor Date: Sun, 22 Feb 2026 22:01:16 -0300 Subject: [PATCH] fix: break Discord typing loop on persistent HTTP failure The typing indicator loop catches all exceptions with bare except/pass, so a permanent HTTP failure (client closed, auth error, etc.) causes the loop to spin every 8 seconds doing nothing until the channel is explicitly stopped. Log the error and exit the loop instead, letting the task clean up naturally. --- nanobot/channels/discord.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/nanobot/channels/discord.py b/nanobot/channels/discord.py index 1d2d7a6..b9227fb 100644 --- a/nanobot/channels/discord.py +++ b/nanobot/channels/discord.py @@ -285,8 +285,11 @@ class DiscordChannel(BaseChannel): while self._running: try: await self._http.post(url, headers=headers) - except Exception: - pass + except asyncio.CancelledError: + return + except Exception as e: + logger.debug("Discord typing indicator failed for {}: {}", channel_id, e) + return await asyncio.sleep(8) self._typing_tasks[channel_id] = asyncio.create_task(typing_loop())