From 4ca8ab37bb3c3448ce29d0170c043467639b8b03 Mon Sep 17 00:00:00 2001 From: Taku Kodma <79110363+risu729@users.noreply.github.com> Date: Tue, 19 May 2026 11:48:18 +1000 Subject: [PATCH 1/4] fix(doctor): honor http timeout for version checks --- e2e/cli/test_doctor_http_timeout | 68 ++++++++++++++++++++++++++++++++ src/http.rs | 5 +-- 2 files changed, 69 insertions(+), 4 deletions(-) create mode 100644 e2e/cli/test_doctor_http_timeout diff --git a/e2e/cli/test_doctor_http_timeout b/e2e/cli/test_doctor_http_timeout new file mode 100644 index 0000000000..468b6d631e --- /dev/null +++ b/e2e/cli/test_doctor_http_timeout @@ -0,0 +1,68 @@ +#!/usr/bin/env bash + +VERSION_SERVER_PORT_FILE="$TMPDIR/version_server_port" + +python3 - </dev/null || true +} +trap cleanup EXIT + +wait_for_file "$VERSION_SERVER_PORT_FILE" "version server port" 5 "$VERSION_SERVER_PID" +VERSION_SERVER_PORT="$(cat "$VERSION_SERVER_PORT_FILE")" + +export MISE_HTTP_RETRIES=0 +export MISE_HTTP_TIMEOUT=5s +export MISE_URL_REPLACEMENTS="{\"https://mise.en.dev/VERSION\":\"http://127.0.0.1:$VERSION_SERVER_PORT/VERSION\"}" + +eval "$(mise activate bash)" && _mise_hook + +STATUS=0 +OUTPUT="$(MISE_DEBUG=1 mise doctor 2>&1)" || STATUS=$? + +if [[ $STATUS -ne 0 ]]; then + printf '%s\n' "$OUTPUT" + fail "mise doctor failed with status $STATUS" +fi + +if [[ $OUTPUT == *"HTTP timed out"* ]]; then + printf '%s\n' "$OUTPUT" + fail "mise doctor version check should honor MISE_HTTP_TIMEOUT" +fi + +if [[ $OUTPUT != *"self_update_available"* ]]; then + printf '%s\n' "$OUTPUT" + fail "mise doctor did not complete successfully" +fi diff --git a/src/http.rs b/src/http.rs index 0c62390b3c..4ac6180687 100644 --- a/src/http.rs +++ b/src/http.rs @@ -25,7 +25,7 @@ use crate::{env, file}; #[cfg(not(test))] pub static HTTP_VERSION_CHECK: Lazy = - Lazy::new(|| Client::new(Duration::from_secs(3), ClientKind::VersionCheck).unwrap()); + Lazy::new(|| Client::new(Settings::get().http_timeout(), ClientKind::Http).unwrap()); pub static HTTP: Lazy = Lazy::new(|| Client::new(Settings::get().http_timeout(), ClientKind::Http).unwrap()); @@ -57,8 +57,6 @@ pub struct Client { enum ClientKind { Http, Fetch, - #[allow(dead_code)] - VersionCheck, } impl Client { @@ -457,7 +455,6 @@ impl Client { "fetch_remote_versions_timeout", "MISE_FETCH_REMOTE_VERSIONS_TIMEOUT", ), - ClientKind::VersionCheck => ("version_check_timeout", ""), }; let hint = if env_var.is_empty() { format!( From a7ab4c886737947330ed9824ea04cb483de928cd Mon Sep 17 00:00:00 2001 From: Taku Kodma <79110363+risu729@users.noreply.github.com> Date: Tue, 19 May 2026 12:02:55 +1000 Subject: [PATCH 2/4] refactor(http): reuse shared client for version checks --- src/cli/version.rs | 2 +- src/http.rs | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/cli/version.rs b/src/cli/version.rs index b2946d7f5c..e4a2eff928 100644 --- a/src/cli/version.rs +++ b/src/cli/version.rs @@ -168,7 +168,7 @@ async fn get_latest_version_call() -> Option { async fn get_latest_version_call() -> Option { 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()) diff --git a/src/http.rs b/src/http.rs index 4ac6180687..9b0b1a1695 100644 --- a/src/http.rs +++ b/src/http.rs @@ -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 = - Lazy::new(|| Client::new(Settings::get().http_timeout(), ClientKind::Http).unwrap()); - pub static HTTP: Lazy = Lazy::new(|| Client::new(Settings::get().http_timeout(), ClientKind::Http).unwrap()); From 8ff05a78984619bc41f303a668b3c29aae5d57e4 Mon Sep 17 00:00:00 2001 From: Taku Kodma <79110363+risu729@users.noreply.github.com> Date: Tue, 19 May 2026 12:21:13 +1000 Subject: [PATCH 3/4] refactor(http): simplify timeout hint --- src/http.rs | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/src/http.rs b/src/http.rs index 9b0b1a1695..74c58e727e 100644 --- a/src/http.rs +++ b/src/http.rs @@ -452,21 +452,13 @@ impl Client { "MISE_FETCH_REMOTE_VERSIONS_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)); From 86d2bcd9c712a22775c6aeec772cdf654cbf7151 Mon Sep 17 00:00:00 2001 From: Taku Kodma <79110363+risu729@users.noreply.github.com> Date: Tue, 19 May 2026 21:18:33 +1000 Subject: [PATCH 4/4] test(doctor): remove http timeout e2e coverage --- e2e/cli/test_doctor_http_timeout | 68 -------------------------------- 1 file changed, 68 deletions(-) delete mode 100644 e2e/cli/test_doctor_http_timeout diff --git a/e2e/cli/test_doctor_http_timeout b/e2e/cli/test_doctor_http_timeout deleted file mode 100644 index 468b6d631e..0000000000 --- a/e2e/cli/test_doctor_http_timeout +++ /dev/null @@ -1,68 +0,0 @@ -#!/usr/bin/env bash - -VERSION_SERVER_PORT_FILE="$TMPDIR/version_server_port" - -python3 - </dev/null || true -} -trap cleanup EXIT - -wait_for_file "$VERSION_SERVER_PORT_FILE" "version server port" 5 "$VERSION_SERVER_PID" -VERSION_SERVER_PORT="$(cat "$VERSION_SERVER_PORT_FILE")" - -export MISE_HTTP_RETRIES=0 -export MISE_HTTP_TIMEOUT=5s -export MISE_URL_REPLACEMENTS="{\"https://mise.en.dev/VERSION\":\"http://127.0.0.1:$VERSION_SERVER_PORT/VERSION\"}" - -eval "$(mise activate bash)" && _mise_hook - -STATUS=0 -OUTPUT="$(MISE_DEBUG=1 mise doctor 2>&1)" || STATUS=$? - -if [[ $STATUS -ne 0 ]]; then - printf '%s\n' "$OUTPUT" - fail "mise doctor failed with status $STATUS" -fi - -if [[ $OUTPUT == *"HTTP timed out"* ]]; then - printf '%s\n' "$OUTPUT" - fail "mise doctor version check should honor MISE_HTTP_TIMEOUT" -fi - -if [[ $OUTPUT != *"self_update_available"* ]]; then - printf '%s\n' "$OUTPUT" - fail "mise doctor did not complete successfully" -fi