Skip to content

Commit

Permalink
fix: download keeps failing if it takes more than 30s (jdx#2224)
Browse files Browse the repository at this point in the history
  • Loading branch information
roele authored May 31, 2024
1 parent 5a6ea6a commit cca3a8a
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/cli/settings/ls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ mod tests {
go_set_gopath = false
go_set_goroot = true
go_skip_checksum = false
http_timeout = 30
jobs = 2
legacy_version_file = true
legacy_version_file_disable_tools = []
Expand Down Expand Up @@ -117,6 +118,7 @@ mod tests {
go_set_gopath
go_set_goroot
go_skip_checksum
http_timeout
jobs
legacy_version_file
legacy_version_file_disable_tools
Expand Down
2 changes: 2 additions & 0 deletions src/cli/settings/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ impl SettingsSet {
"go_set_gopath" => parse_bool(&self.value)?,
"go_set_goroot" => parse_bool(&self.value)?,
"go_skip_checksum" => parse_bool(&self.value)?,
"http_timeout" => parse_i64(&self.value)?,
"jobs" => parse_i64(&self.value)?,
"legacy_version_file" => parse_bool(&self.value)?,
"node_compile" => parse_bool(&self.value)?,
Expand Down Expand Up @@ -139,6 +140,7 @@ pub mod tests {
go_set_gopath = false
go_set_goroot = true
go_skip_checksum = false
http_timeout = 30
jobs = 2
legacy_version_file = false
legacy_version_file_disable_tools = []
Expand Down
1 change: 1 addition & 0 deletions src/cli/settings/unset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ mod tests {
go_set_gopath = false
go_set_goroot = true
go_skip_checksum = false
http_timeout = 30
jobs = 2
legacy_version_file = true
legacy_version_file_disable_tools = []
Expand Down
2 changes: 2 additions & 0 deletions src/config/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ pub struct Settings {
/// set to true to skip checksum verification when downloading go sdk tarballs
#[config(env = "MISE_GO_SKIP_CHECKSUM", default = false)]
pub go_skip_checksum: bool,
#[config(env = "MISE_HTTP_TIMEOUT", default = 30)]
pub http_timeout: u64,
#[config(env = "MISE_JOBS", default = 4)]
pub jobs: usize,
#[config(env = "MISE_LEGACY_VERSION_FILE", default = true)]
Expand Down
4 changes: 3 additions & 1 deletion src/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use tokio::runtime::Runtime;
use url::Url;

use crate::cli::version;
use crate::config::Settings;
use crate::env::MISE_FETCH_REMOTE_VERSIONS_TIMEOUT;
use crate::file::display_path;
use crate::ui::progress_report::SingleReport;
Expand All @@ -19,7 +20,8 @@ use crate::{env, file};
pub static HTTP_VERSION_CHECK: Lazy<Client> =
Lazy::new(|| Client::new(Duration::from_secs(3)).unwrap());

pub static HTTP: Lazy<Client> = Lazy::new(|| Client::new(Duration::from_secs(30)).unwrap());
pub static HTTP: Lazy<Client> =
Lazy::new(|| Client::new(Duration::from_secs(Settings::get().http_timeout)).unwrap());

pub static HTTP_FETCH: Lazy<Client> =
Lazy::new(|| Client::new(*MISE_FETCH_REMOTE_VERSIONS_TIMEOUT).unwrap());
Expand Down

0 comments on commit cca3a8a

Please sign in to comment.