Skip to content

fix(telegram): check updater/app state before disconnect#1197

Closed
usvimal wants to merge 1 commit intoNousResearch:mainfrom
usvimal:fix/telegram-disconnect-error-handling
Closed

fix(telegram): check updater/app state before disconnect#1197
usvimal wants to merge 1 commit intoNousResearch:mainfrom
usvimal:fix/telegram-disconnect-error-handling

Conversation

@usvimal
Copy link
Contributor

@usvimal usvimal commented Mar 13, 2026

Problem

The method unconditionally called and , causing spurious errors during gateway shutdown:

These errors were caught and logged as warnings, but they represent expected states during shutdown, not actual problems.

Solution

Check if the updater and app are actually running before attempting to stop them.

Changes

  • Check before calling
  • Check before calling
  • Only log warnings for unexpected errors, not normal shutdown states

This eliminates noise in the logs during graceful shutdown.

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.
@teknium1
Copy link
Contributor

Merged via PR #1389. Your substantive fix was cherry-picked onto current main with authorship preserved, and I added a regression test on top. Thanks.

@teknium1 teknium1 closed this Mar 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants