diff --git a/plugins/platforms/telegram/adapter.py b/plugins/platforms/telegram/adapter.py index b23bdcf8d33..3fa37f94aed 100644 --- a/plugins/platforms/telegram/adapter.py +++ b/plugins/platforms/telegram/adapter.py @@ -3025,8 +3025,11 @@ class TelegramAdapter(BasePlatformAdapter): def _with_limits(httpx_kwargs: Optional[dict] = None) -> dict: """Merge tuned keepalive limits into httpx client kwargs. - A caller-supplied ``limits`` (none today) is left untouched; - otherwise the CLOSE_WAIT-safe limits are injected. + Used by the proxy and direct-DNS branches, where httpx honours + the client-level ``limits`` kwarg. A caller-supplied ``limits`` + is left untouched; otherwise the CLOSE_WAIT-safe limits are + injected. The fallback-IP branch does NOT use this helper — see + the ``_transport_kwargs`` note below for why. """ kwargs = dict(httpx_kwargs or {}) if _pool_limits is not None and "limits" not in kwargs: @@ -3055,9 +3058,12 @@ class TelegramAdapter(BasePlatformAdapter): # Keep request/update pools separate to reduce contention during # polling reconnect + bot API bootstrap/delete_webhook calls. # httpx ignores the client-level `limits` kwarg when a custom - # `transport` is supplied (#58790). Pass the tuned limits + # `transport` is supplied (#58790). Unlike the proxy/direct + # branches (which inject limits at the client level via + # `_with_limits`), this branch MUST pass the tuned limits # directly into TelegramFallbackTransport so its inner - # AsyncHTTPTransport instances honour keepalive_expiry. + # AsyncHTTPTransport instances honour keepalive_expiry — do not + # route this through `_with_limits`, httpx would discard it. _transport_kwargs: dict = {} if _pool_limits is not None: _transport_kwargs["limits"] = _pool_limits