fix(events): set 300s timeout on export HTTP clients#302
Conversation
The export() and export_async() methods created httpx.Client / httpx.AsyncClient without an explicit timeout, inheriting the httpx default of 5 seconds. Large result sets (e.g. 7500 events) need 30-80 seconds on the wire, so every such request hit ReadTimeout and the retry loop amplified it to ~27 s of wasted retries. Add a module-level EXPORT_TIMEOUT = httpx.Timeout(300.0) constant and pass it to both client constructors so exports can complete even on very large queries. Co-Authored-By: Dhruv <dhruv@honeyhive.ai>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
|
Claude finished @devin-ai-integration[bot]'s task in 1m 0s —— View job Review of PR #302 — Complete
SummaryThe fix is correct and well-targeted — adding I left two inline comments:
No documentation impact — this is a behavioral bugfix with no public API surface changes. |
Overall ReviewThe fix is correct and well-targeted. The root cause (httpx 5s default timeout vs 30-80s real-world export times) is clearly identified, and applying a longer timeout to the two export HTTP clients is the right approach. What looks good:
Suggestions (non-blocking):
No documentation impact — this is a behavioral bugfix with no public API changes; no updates needed to Overall this is a solid, focused bugfix. Approve once the optional timeout split is considered. |
|
📚 Documentation preview built — Download artifact Review instructions & validation statusHow to Review
Validation Status
|
Apply review suggestions: - Use split httpx.Timeout(connect=10, read=300, write=30, pool=10) so unreachable hosts fail fast while only read gets the 300s budget - Remove unused asyncio import from test file Co-Authored-By: Dhruv <dhruv@honeyhive.ai>
|
📚 Documentation preview built — Download artifact Review instructions & validation statusHow to Review
Validation Status
|
Co-Authored-By: Dhruv <dhruv@honeyhive.ai>
|
📚 Documentation preview built — Download artifact Review instructions & validation statusHow to Review
Validation Status
|
fix(events): set 300s timeout on export HTTP clients
Summary
export()andexport_async()createhttpx.Client/httpx.AsyncClientwithout specifying a timeout, inheriting httpx's 5-second default. Large event exports (e.g. 7500 events viaget_by_session_id()) take 30-80s on the wire, so every such request hitsReadTimeout. The retry loop (3 retries with backoff) amplifies this into ~27s of wasted time before final failure.Fix: Adds a module-level
EXPORT_TIMEOUTconstant with split timeout values and passes it to both httpx client constructors. Uses short timeouts for connect/write/pool (10-30s) to fail fast on unreachable hosts, while giving read 300s to accommodate large result sets. Validated against staging — 7500 events now return successfully in ~79s instead of timing out.Changes:
src/honeyhive/api/client.py— addEXPORT_TIMEOUT = httpx.Timeout(connect=10.0, read=300.0, write=30.0, pool=10.0)constant, passtimeout=EXPORT_TIMEOUTto bothhttpx.Clientandhttpx.AsyncClienttests_v2/unit/test_events_export_timeout.py— 8 unit tests covering the constant value, syncexport(), asyncexport_async(), andget_by_session_id_async()delegationCHANGELOG.md— customer-facing entry under[Unreleased] > Fixedexamples/integrations/strands_agents_example.py— unrelatedblackformatting fix (resolves pre-existing Generated Code Check CI failure)Review & Testing Checklist for Human
get_by_session_id()returning 5000+ events) against staging or production. Unit tests mock the HTTP layer, so they verify the timeout is passed but cannot confirm real-world behavior.connect=10.0, read=300.0, write=30.0, pool=10.0— particularly verify that 10s connect is enough for high-latency customer networks.HoneyHive(timeout=...).Notes
export_async(limit=7500)→ReadTimeoutafter 27s (4 attempts × 5s + backoff). After fix: 7500 events returned in 78.92s.timeout=None. This is a regression introduced in the federated SDK's direct httpx usage.