Skip to content

Commit 4238110

Browse files
committed
fix(registry): explicitly specify a five-second timeout for downloading registry
1 parent 3fe54af commit 4238110

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

crates/tabby-common/src/registry.rs

+21-9
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,27 @@ fn models_json_file(registry: &str) -> PathBuf {
4040
}
4141

4242
async fn load_remote_registry(registry: &str) -> Result<Vec<ModelInfo>> {
43-
let model_info = reqwest::get(format!(
44-
"https://raw.githubusercontent.com/{}/registry-tabby/main/models.json",
45-
registry
46-
))
47-
.await
48-
.context("Failed to download")?
49-
.json()
50-
.await
51-
.context("Failed to get JSON")?;
43+
// Create a client with custom timeout.
44+
// There have been instances where requests did not adhere to the default timeout,
45+
// resulting in requests hanging indefinitely.
46+
// Therefore, it's necessary to specify a custom timeout.
47+
let client = reqwest::Client::builder()
48+
.timeout(std::time::Duration::from_secs(5))
49+
.build()
50+
.context("Failed to build HTTP client")?;
51+
52+
let model_info = client
53+
.get(format!(
54+
"https://raw.githubusercontent.com/{}/registry-tabby/main/models.json",
55+
registry
56+
))
57+
.send()
58+
.await
59+
.context("Failed to download")?
60+
.json()
61+
.await
62+
.context("Failed to get JSON")?;
63+
5264
let dir = models_dir().join(registry);
5365
// We don't want to fail if the TabbyML directory already exists,
5466
// which is exactly, what `create_dir_all` will do, see

0 commit comments

Comments
 (0)