-
Notifications
You must be signed in to change notification settings - Fork 17
fix(http): disable connection pooling to prevent stale connections in Lambda #1094
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -173,14 +173,25 @@ pub fn create_client( | |
| let proxy = | ||
| hyper_http_proxy::Proxy::new(hyper_http_proxy::Intercept::Https, proxy.parse()?); | ||
| let proxy_connector = hyper_http_proxy::ProxyConnector::from_proxy(connector, proxy)?; | ||
| let client = http_common::client_builder().build(proxy_connector); | ||
| // Disable connection pooling to avoid stale connections after Lambda freeze/resume. | ||
| // In Lambda, the execution environment can be frozen for seconds to minutes between | ||
| // invocations. Pooled connections become stale during this time, causing failures | ||
| // when reused. Setting pool_max_idle_per_host(0) ensures each request gets a fresh | ||
| // connection, matching the pattern used in libdatadog's new_client_periodic(). | ||
| let client = http_common::client_builder() | ||
| .pool_max_idle_per_host(0) | ||
| .build(proxy_connector); | ||
| debug!( | ||
| "HTTP_CLIENT | Proxy connector created with proxy: {:?}", | ||
| proxy_https | ||
| ); | ||
| Ok(client) | ||
| } else { | ||
| let proxy_connector = hyper_http_proxy::ProxyConnector::new(connector)?; | ||
| Ok(http_common::client_builder().build(proxy_connector)) | ||
| // Disable connection pooling to avoid stale connections after Lambda freeze/resume. | ||
| // See comment above for detailed explanation. | ||
| Ok(http_common::client_builder() | ||
| .pool_max_idle_per_host(0) | ||
| .build(proxy_connector)) | ||
|
Comment on lines
+191
to
+195
|
||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pooling configuration and explanatory comment are duplicated across both proxy branches. To reduce drift risk and simplify future changes, consider factoring the builder configuration into a single
let builder = http_common::client_builder().pool_max_idle_per_host(0);(or a small helper) and reuse it for bothbuild(...)calls; likewise, keep one canonical comment (or a brief reference) in one place.