fix(polling): httpx client timeout 改為分開設定,read=50s > getUpdates 40s
Some checks failed
CD Pipeline / build-and-deploy (push) Has been cancelled

根因: httpx.AsyncClient(timeout=30.0) 的 read timeout 30s
     < getUpdates 的 long polling timeout 40s
     導致每次 getUpdates 都被 client 打斷 → polling loop 無法正常收訊息

修法: httpx.Timeout(connect=10s, read=50s) 讓 long polling 正常等待

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
OG T
2026-04-03 18:29:22 +08:00
parent dfc1e19c07
commit d1436157b7

View File

@@ -1085,8 +1085,11 @@ class TelegramGateway:
logger.warning("telegram_gateway_disabled", reason="Chat ID not configured")
return False
# 2026-04-03 ogt: timeout 改用 httpx.Timeout 分開設定
# connect=10s, read=50s (getUpdates long polling timeout 40s + buffer)
# 舊的 timeout=30.0 會讓 getUpdates(timeout=40s) 每次都被 client 先打斷
self._http_client = httpx.AsyncClient(
timeout=30.0,
timeout=httpx.Timeout(connect=10.0, read=50.0, write=10.0, pool=10.0),
headers={"Content-Type": "application/json"},
)