From 91ca378c1ff427736b02a2356206dc96599a6ed2 Mon Sep 17 00:00:00 2001 From: rami3l Date: Mon, 3 Jun 2024 14:52:49 +0800 Subject: [PATCH] fix(download): work around `hyper` hang issue by adjusting `reqwest` config --- download/src/lib.rs | 4 ++++ download/tests/read-proxy-env.rs | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/download/src/lib.rs b/download/src/lib.rs index 20b1bf2dc3..8c2f9892cc 100644 --- a/download/src/lib.rs +++ b/download/src/lib.rs @@ -345,6 +345,10 @@ pub mod reqwest_be { fn client_generic() -> ClientBuilder { Client::builder() + // HACK: set `pool_max_idle_per_host` to `0` to avoid an issue in the underlying + // `hyper` library that causes the `reqwest` client to hang in some cases. + // See for more details. + .pool_max_idle_per_host(0) .gzip(false) .proxy(Proxy::custom(env_proxy)) .timeout(Duration::from_secs(30)) diff --git a/download/tests/read-proxy-env.rs b/download/tests/read-proxy-env.rs index 1ebc2843eb..ca90983d38 100644 --- a/download/tests/read-proxy-env.rs +++ b/download/tests/read-proxy-env.rs @@ -61,6 +61,10 @@ async fn socks_proxy_request() { let url = Url::parse("http://192.168.0.1/").unwrap(); let client = Client::builder() + // HACK: set `pool_max_idle_per_host` to `0` to avoid an issue in the underlying + // `hyper` library that causes the `reqwest` client to hang in some cases. + // See for more details. + .pool_max_idle_per_host(0) .proxy(Proxy::custom(env_proxy)) .timeout(Duration::from_secs(1)) .build()