Skip to content

Commit b2e1d7e

Browse files
committed
Set tight HTTP timeouts on GrowthBook feature fetches
The SDK defaults to no timeout, so a slow CDN response could block a worker indefinitely on the periodic refresh. Set http_connect_timeout=1 and http_read_timeout=2 on both the warmup and per-request instances.
1 parent e69e17a commit b2e1d7e

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

app/backend/src/couchers/experimentation.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ def setup_experimentation() -> None:
4545
gb = GrowthBook(
4646
api_host=config["GROWTHBOOK_API_HOST"],
4747
client_key=config["GROWTHBOOK_CLIENT_KEY"],
48+
http_connect_timeout=1,
49+
http_read_timeout=2,
4850
)
4951
gb.load_features()
5052
test_gate_result = gb.is_on("test_growthbook_integration")
@@ -72,6 +74,8 @@ def _get_growthbook(context: CouchersContext) -> GrowthBook:
7274
api_host=config["GROWTHBOOK_API_HOST"],
7375
client_key=config["GROWTHBOOK_CLIENT_KEY"],
7476
attributes={"id": str(context.user_id)},
77+
http_connect_timeout=1,
78+
http_read_timeout=2,
7579
)
7680
gb.load_features()
7781
context._growthbook = gb # type: ignore[attr-defined]

0 commit comments

Comments
 (0)