Browse Source

fix double serialize on invoke (#5639)

Co-authored-by: LucasJavaudin <lucas.javaudin@cyu.fr>
Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
LucasJavaudin 2 years ago
parent
commit
677838ccfa
2 changed files with 10 additions and 1 deletions
  1. 5 0
      .changes/fix-invoke-double-serialize.md
  2. 5 1
      core/tauri/src/hooks.rs

+ 5 - 0
.changes/fix-invoke-double-serialize.md

@@ -0,0 +1,5 @@
+---
+"tauri": patch
+---
+
+Fixes a double serialization on the IPC.

+ 5 - 1
core/tauri/src/hooks.rs

@@ -193,7 +193,11 @@ impl<R: Runtime> InvokeResolver<R> {
     F: Future<Output = Result<JsonValue, InvokeError>> + Send + 'static,
   {
     crate::async_runtime::spawn(async move {
-      Self::return_result(self.window, task.await.into(), self.callback, self.error)
+      let response = match task.await {
+        Ok(ok) => InvokeResponse::Ok(ok),
+        Err(err) => InvokeResponse::Err(err),
+      };
+      Self::return_result(self.window, response, self.callback, self.error)
     });
   }