fix(api): bound billing service HTTP timeouts (#39874) (#39875)

Co-authored-by: Harsh Kashyap <Harsh23Kashyap@users.noreply.github.com>
This commit is contained in:
Harsh Kashyap 2026-08-01 16:16:13 +05:30 committed by GitHub
parent f6832fddee
commit eec0e2e44e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 1 deletions

View File

@ -21,7 +21,10 @@ logger = logging.getLogger(__name__)
_http_client: httpx.Client = get_pooled_http_client(
"billing:default",
lambda: httpx.Client(limits=httpx.Limits(max_keepalive_connections=50, max_connections=100)),
lambda: httpx.Client(
timeout=httpx.Timeout(30.0, connect=5.0),
limits=httpx.Limits(max_keepalive_connections=50, max_connections=100),
),
)

View File

@ -2055,3 +2055,17 @@ class TestBillingServiceSubscriptionInfoDataType:
with pytest.raises(ValidationError):
BillingService.get_info("tenant-type-test")
def test_pooled_billing_client_carries_bounded_timeout() -> None:
"""Regression for #39874: the pooled billing client must carry a
read/connect timeout so a stalled Stripe / cloud-billing proxy
fails fast instead of pinning a worker. Same shape as the
JinaReader / WaterCrawl hardening that landed in PR #39860 and #39824.
"""
import services.billing_service as billing_service_module
client = billing_service_module._http_client
assert client.timeout is not None
assert client.timeout.read == 30.0
assert client.timeout.connect == 5.0