Skip to content

Commit 25fc1dc

Browse files
authored
fix(registry): explicitly specify a five-second timeout for downloadi… (#4120)
* fix(registry): explicitly specify a five-second timeout for downloading registry * chore: update comments
1 parent 3fe54af commit 25fc1dc

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

crates/tabby-common/src/registry.rs

+20-9
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,26 @@ 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 an HTTP client with a custom timeout.
44+
// This is necessary because the default timeout settings can sometimes cause requests to hang indefinitely.
45+
// To prevent such issues, we specify a custom timeout duration.
46+
let client = reqwest::Client::builder()
47+
.timeout(std::time::Duration::from_secs(5))
48+
.build()
49+
.context("Failed to build HTTP client")?;
50+
51+
let model_info = client
52+
.get(format!(
53+
"https://raw.githubusercontent.com/{}/registry-tabby/main/models.json",
54+
registry
55+
))
56+
.send()
57+
.await
58+
.context("Failed to download")?
59+
.json()
60+
.await
61+
.context("Failed to get JSON")?;
62+
5263
let dir = models_dir().join(registry);
5364
// We don't want to fail if the TabbyML directory already exists,
5465
// which is exactly, what `create_dir_all` will do, see

0 commit comments

Comments
 (0)