DeepSeek Harness Tauri 桌面版 | Only 8mb installer, zero environment setup, preset plugins, Windows / macOS / Linux.
fix(workflow): bypass proxy for loopback health checks
idealclover4d22088ea78e
diff --git a/src-tauri/src/service/workflow/mod.rs b/src-tauri/src/service/workflow/mod.rsindex 33a2451e..a0424e82 100644--- a/src-tauri/src/service/workflow/mod.rs+++ b/src-tauri/src/service/workflow/mod.rs@@ -878,10 +878,9 @@ pub async fn proxy_health_check(port: u16) -> Result<String, String> {if !has_owned_process() {return Err("HARNESS_NOT_OWNED: no Harness process is owned by this app".to_string());}- let client = reqwest::Client::builder()- .timeout(config::HEALTH_CHECK_TIMEOUT)- .build()- .map_err(|e| e.to_string())?;+ let client = utils::loopback_http_client(config::HEALTH_CHECK_TIMEOUT)+ .map_err(|e| format!("HARNESS_HEALTH_CLIENT_FAILED: {e}"))?;+ let mut failures = Vec::with_capacity(2);for endpoint in [format!("http://127.0.0.1:{port}/"),@@ -897,13 +896,20 @@ pub async fn proxy_health_check(port: u16) -> Result<String, String> {body.chars().take(80).collect::<String>()));}+ let failure = format!("{endpoint} returned {status}");+ log::debug!("Health check failed: {failure}");+ failures.push(failure);}Err(err) => {log::debug!("Health check {endpoint}: {err}");+ failures.push(format!("{endpoint}: {err}"));}}}- Err("HARNESS_NOT_READY: Harness service is not ready".to_string())+ Err(format!(+ "HARNESS_NOT_READY: Harness service is not ready ({})",+ failures.join("; ")+ ))}#[cfg(test)]diff --git a/src-tauri/src/service/workflow/utils.rs b/src-tauri/src/service/workflow/utils.rsindex 4949d8d6..042dd62e 100644--- a/src-tauri/src/service/workflow/utils.rs+++ b/src-tauri/src/service/workflow/utils.rs@@ -12,12 +12,21 @@ fn dsh_log_lock() -> &'static Mutex<()> {DSH_LOG_LOCK.get_or_init(|| Mutex::new(()))}+/// 构造仅用于回环地址探测的 HTTP 客户端。+///+/// 生命周期探测访问的是本机 dsh,不能继承 `HTTP_PROXY` / `ALL_PROXY`:部分代理+/// 不尊重回环地址直连,或应用进程没有 `NO_PROXY`,会把健康检查转发到外部代理,+/// 造成端口已经监听但持续误报未就绪。+pub(super) fn loopback_http_client(timeout: Duration) -> Result<reqwest::Client, reqwest::Error> {+ reqwest::Client::builder()+ .no_proxy()+ .timeout(timeout)+ .build()+}+/// 检查 Harness 是否真正在运行(探测指定端口,随配置端口联动)pub async fn is_dsh_running(port: u16) -> bool {- let client = reqwest::Client::builder()- .timeout(Duration::from_secs(2))- .build()- .ok(); // 将 Result 转为 Option+ let client = loopback_http_client(Duration::from_secs(2)).ok(); // 将 Result 转为 Option// 如果 client 创建失败,直接返回 falselet client = match client {