Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/cli/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ async fn get_latest_version_call() -> Option<String> {
async fn get_latest_version_call() -> Option<String> {
let url = "https://mise.en.dev/VERSION";
debug!("checking mise version from {}", url);
match crate::http::HTTP_VERSION_CHECK.get_text(url).await {
match crate::http::HTTP.get_text(url).await {
Ok(text) => {
debug!("got version {text}");
Some(text.trim().to_string())
Expand Down
29 changes: 7 additions & 22 deletions src/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ use crate::ui::progress_report::SingleReport;
use crate::ui::time::format_duration;
use crate::{env, file};

#[cfg(not(test))]
pub static HTTP_VERSION_CHECK: Lazy<Client> =
Lazy::new(|| Client::new(Duration::from_secs(3), ClientKind::VersionCheck).unwrap());

pub static HTTP: Lazy<Client> =
Lazy::new(|| Client::new(Settings::get().http_timeout(), ClientKind::Http).unwrap());

Expand Down Expand Up @@ -57,8 +53,6 @@ pub struct Client {
enum ClientKind {
Http,
Fetch,
#[allow(dead_code)]
VersionCheck,
}

impl Client {
Expand Down Expand Up @@ -457,23 +451,14 @@ impl Client {
"fetch_remote_versions_timeout",
"MISE_FETCH_REMOTE_VERSIONS_TIMEOUT",
),
ClientKind::VersionCheck => ("version_check_timeout", ""),
};
let hint = if env_var.is_empty() {
format!(
"HTTP timed out after {} for {}.",
format_duration(self.timeout),
url
)
} else {
format!(
"HTTP timed out after {} for {} (change with `{}` or env `{}`).",
format_duration(self.timeout),
url,
setting,
env_var
)
};
let hint = format!(
"HTTP timed out after {} for {} (change with `{}` or env `{}`).",
format_duration(self.timeout),
url,
setting,
env_var
);
// wrap_err preserves the underlying reqwest::Error in the chain so
// is_transient() can still classify this as a retryable timeout.
return Err(Report::new(err).wrap_err(hint));
Expand Down
Loading