fix(server): set ReadHeaderTimeout and IdleTimeout on all HTTP servers - #1873
Conversation
The connect, metrics, and UI servers were built with only Addr and Handler, so clients could hold connections open forever while withholding request headers or sitting idle. Add two config fields under app, applied to all three servers: - read_header_timeout (default 10s): how long the server waits for request headers. - idle_timeout (default 180s): how long an idle keep-alive connection stays open. The default exceeds common proxy keep-alive timeouts (ALB 60s, nginx 75s); deployments behind a proxy with a longer keep-alive should raise it so the proxy never reuses a connection the server is closing. No WriteTimeout on purpose: the connect server streams long export responses (e.g. ExportAuditRecords) that a write deadline would cut off. Fixes #1819 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughSummary by CodeRabbit
WalkthroughThe change adds ChangesHTTP server timeouts
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Coverage Report for CI Build 31562278057Coverage increased (+0.006%) to 48.103%Details
Uncovered Changes
Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
|
Tested this live. Built the branch and ran server (connect 18002, metrics 19000, UI 18100) against the same local DB. Probed with raw TCP clients that stall mid-request or sit idle on a keep-alive connection.
Defaults fill in when the config file has no timeout keys, and setting |
Fixes #1819.
All three
http.Serverinstances inpkg/server/server.go(connect, metrics, UI) were built with onlyAddrandHandler. Nothing limited how long a client could withhold request headers or keep an idle connection open.idle_timeoutdefault exceeds common proxy keep-alive timeouts (ALB 60s, nginx 75s). Deployments behind a proxy with a longer keep-alive should raise it, so the proxy never sends a request on a connection the server is already closing.WriteTimeouton purpose: the connect server streams long export responses (e.g.ExportAuditRecords) that a write deadline would cut off.ReadTimeouteither; it would need a value that accounts for large request bodies, and the header timeout already covers the slow-client case this issue is about.Testing
go build ./pkg/server/...andgo test ./pkg/server/pass.Loadfills both defaults (10s/180s) when the fields are absent from the config file.🤖 Generated with Claude Code