Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Add timeouts to HTTP client

Antonio Scandurra5df50e2fc97a
diff --git a/crates/client/src/http.rs b/crates/client/src/http.rs
index 5139bb8d03c..0757cebf3ad 100644
--- a/crates/client/src/http.rs
+++ b/crates/client/src/http.rs
@@ -9,7 +9,7 @@ pub use isahc::{
Error,
};
use smol::future::FutureExt;
-use std::sync::Arc;
+use std::{sync::Arc, time::Duration};
pub use url::Url;
pub type Request = isahc::Request<AsyncBody>;
@@ -41,7 +41,13 @@ pub trait HttpClient: Send + Sync {
}
pub fn client() -> Arc<dyn HttpClient> {
- Arc::new(isahc::HttpClient::builder().build().unwrap())
+ Arc::new(
+ isahc::HttpClient::builder()
+ .connect_timeout(Duration::from_secs(5))
+ .low_speed_timeout(100, Duration::from_secs(5))
+ .build()
+ .unwrap(),
+ )
}
impl HttpClient for isahc::HttpClient {