diff --git a/src-tauri/src/core/clash.rs b/src-tauri/src/core/clash.rs
index 0f7a304aa218fa2f795a89e4c9889a9863fd12d0..eb943251d07d605f477a0540c14dc795bbfa8ec8 100644
--- a/src-tauri/src/core/clash.rs
+++ b/src-tauri/src/core/clash.rs
@@ -301,6 +301,9 @@ impl Clash {
     let info = self.info.clone();
     let mut config = self.config.clone();
 
+    // generate the payload
+    let payload = profiles.gen_enhanced()?;
+
     win.once(&event_name, move |event| {
       if let Some(result) = event.payload() {
         let gen_map: Mapping = serde_json::from_str(result).unwrap();
@@ -312,9 +315,6 @@ impl Clash {
       }
     });
 
-    // generate the payload
-    let payload = profiles.gen_enhanced();
-
     tauri::async_runtime::spawn(async move {
       sleep(Duration::from_secs(5)).await;
       win.emit("script-handler", payload).unwrap();
diff --git a/src-tauri/src/core/profiles.rs b/src-tauri/src/core/profiles.rs
index d4504cbd0b0ec04213bd9d08bdc14a91ae3ee068..b12b01f9ea3597a56d95829176b4715c04d62826 100644
--- a/src-tauri/src/core/profiles.rs
+++ b/src-tauri/src/core/profiles.rs
@@ -438,8 +438,8 @@ impl Profiles {
   }
 
   /// gen the enhanced profiles
-  pub fn gen_enhanced(&self) -> PrfEnhanced {
-    let current = self.gen_activate().unwrap();
+  pub fn gen_enhanced(&self) -> Result<PrfEnhanced> {
+    let current = self.gen_activate()?;
 
     let chain = match self.chain.as_ref() {
       Some(chain) => chain
@@ -454,7 +454,7 @@ impl Profiles {
       None => vec![],
     };
 
-    PrfEnhanced { current, chain }
+    Ok(PrfEnhanced { current, chain })
   }
 }