Skip to content

fix: Telegram Bot API client has no deadline, so startup and sends can hang forever#889

Open
sam-saffron-jarvis wants to merge 1 commit into
SamSaffron:mainfrom
sam-saffron-jarvis:feat/codereview-85d44b23
Open

fix: Telegram Bot API client has no deadline, so startup and sends can hang forever#889
sam-saffron-jarvis wants to merge 1 commit into
SamSaffron:mainfrom
sam-saffron-jarvis:feat/codereview-85d44b23

Conversation

@sam-saffron-jarvis

Copy link
Copy Markdown
Contributor

What changed

  • Construct the Telegram Bot API client with NewBotAPIWithClient instead of the library default unbounded http.Client.
  • Added a small HTTP client wrapper that applies a 30s deadline to normal Bot API calls (getMe, sends, edits, getFile) and a 70s deadline to getUpdates, preserving the existing 60s long-poll window with slack.
  • Added regression tests covering startup timeout, send timeout, and long-poll requests outliving the regular request timeout.

Why this is high-value

Sam/Jarvis uses the Telegram surface routinely, and this client is on every serve --telegram startup, every long-poll request, and every reply/edit while streaming. Before this change, a stalled Telegram API/network call could block startup forever or wedge a per-chat stream while holding the session mutex, preventing later messages, /reset, and cleanup for that chat from making progress.

Validation

  • go test ./internal/serve -run 'TestTelegramBotAPIClient' -count=1 -v
  • go build ./...
  • go test ./...
  • git diff --check

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.

1 participant