fix(telegram): resolve getUpdates long-poll timeout race (#361)

HTTP client timeout (30s) equaled getUpdates API timeout (30s), causing
context deadline exceeded errors (~210/hr) when Telegram held the
long-poll for the full duration. Increase HTTP client to 60s, reduce
getUpdates to 25s for 35s headroom.

Closes #361
This commit is contained in:
viettranx committed 2026-03-23 12:04:49 +07:00
1 parent 94f6bf2445
commit 2739984aed
1 file changed
+2 -2
+2 -2
View File
@@ -83,7 +83,7 @@ func New(cfg config.TelegramConfig, msgBus *bus.MessageBus, pairingSvc store.Pai
}
httpClient := &http.Client{
Timeout: 30 * time.Second,
Timeout: 60 * time.Second, // Must exceed getUpdates Timeout to avoid long-poll race (#361)
Transport: transport,
}
// Apply ForceIPv4 at init if configured (explicit, predictable, no runtime heuristic).
@@ -139,7 +139,7 @@ func (c *Channel) Start(ctx context.Context) error {
c.pollDone = make(chan struct{})
updates, err := c.bot.UpdatesViaLongPolling(pollCtx, &telego.GetUpdatesParams{
Timeout: 30,
Timeout: 25, // Long-poll seconds; keep below HTTP client Timeout (#361)
AllowedUpdates: []string{
"message",
"edited_message",