From 0c182211a134fba08526469de1c5a811d59efd6b Mon Sep 17 00:00:00 2001 From: Vimal Date: Fri, 13 Mar 2026 18:37:20 +0000 Subject: [PATCH] fix(telegram): check updater/app state before disconnect The disconnect() method was unconditionally calling updater.stop() and app.stop(), causing errors when: - The updater was not running (RuntimeError: This Updater is not running!) - The app was None (AttributeError: 'NoneType' object has no attribute) Changes: - Check if updater exists and is running before stopping - Check if app is running before stopping - Only log warnings for actual errors, not expected shutdown states Fixes spurious warnings during gateway shutdown. --- gateway/platforms/telegram.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gateway/platforms/telegram.py b/gateway/platforms/telegram.py index 833c95c8..790061ec 100644 --- a/gateway/platforms/telegram.py +++ b/gateway/platforms/telegram.py @@ -275,8 +275,11 @@ class TelegramAdapter(BasePlatformAdapter): if self._app: try: - await self._app.updater.stop() - await self._app.stop() + # Only stop the updater if it's running + if self._app.updater and self._app.updater.running: + await self._app.updater.stop() + if self._app.running: + await self._app.stop() await self._app.shutdown() except Exception as e: logger.warning("[%s] Error during Telegram disconnect: %s", self.name, e, exc_info=True)