From cf29b714d329734e8b8681d70d1d934d70f2be71 Mon Sep 17 00:00:00 2001 From: oomeow Date: Sat, 1 Aug 2026 17:01:39 +0800 Subject: [PATCH] feat(runstate): retry service version probing --- src-tauri/src/core/runstate/mod.rs | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/src-tauri/src/core/runstate/mod.rs b/src-tauri/src/core/runstate/mod.rs index 6d7d2d032..489891b57 100644 --- a/src-tauri/src/core/runstate/mod.rs +++ b/src-tauri/src/core/runstate/mod.rs @@ -24,8 +24,9 @@ use std::{ time::Duration, }; -use anyhow::{Context as _, Result, bail}; +use anyhow::{Context as _, Error, Result, bail}; use arc_swap::ArcSwap; +use backon::{ConstantBuilder, Retryable as _}; use clash_verge_logging::{Type, logging}; use once_cell::sync::Lazy; use parking_lot::Mutex; @@ -221,8 +222,27 @@ impl RunStateStore { return classify_service_health(CurrentServiceProbe::Missing, false, ""); } - match self.env.probe_service_version().await { - Ok(reply) => classify_service_health(probe_outcome(&reply), has_marker, ""), + let result = (|| async { + let reply = self.env.probe_service_version().await?; + let service_health = classify_service_health(probe_outcome(&reply), has_marker, ""); + anyhow::Ok(service_health) + }) + .retry( + ConstantBuilder::default() + .with_delay(Duration::from_millis(500)) + .with_max_times(10), + ) + .notify(|err, dur| { + logging!( + warn, + Type::Service, + "get service version failed: {err}, retrying in {dur:?}" + ); + }) + .await; + + match result { + Ok(service_health) => service_health, Err(error) => { logging!(warn, Type::Service, "current service IPC is unavailable: {error:#}"); classify_service_health(