Browse Source

fix(core): make `tauri::Error` sync again (#8777)

* fix(core): make `tauri::Error` sync again

closes #8754

* add unit test

---------

Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
Amr Bashir 1 year ago
parent
commit
2e6db908d7

+ 5 - 0
.changes/tauri-error-sync.md

@@ -0,0 +1,5 @@
+---
+'tauri': 'patch:bug'
+---
+
+Fix regression in `tauri::Error` not being `Sync`.

+ 5 - 0
.changes/tauri-scope-object-error-sync.md

@@ -0,0 +1,5 @@
+---
+'tauri': 'patch:breaking'
+---
+
+Require `ScopeObject::Error` to be `Sync` as well.

+ 10 - 1
core/tauri/src/error.rs

@@ -147,8 +147,17 @@ pub enum Error {
   UnstableFeatureNotSupported,
   /// Failed to deserialize scope object.
   #[error("error deserializing scope: {0}")]
-  CannotDeserializeScope(Box<dyn std::error::Error + Send>),
+  CannotDeserializeScope(Box<dyn std::error::Error + Send + Sync>),
 }
 
 /// `Result<T, ::tauri::Error>`
 pub type Result<T> = std::result::Result<T, Error>;
+
+#[cfg(test)]
+mod tests {
+  #[test]
+  fn error_is_send_sync() {
+    crate::test_utils::assert_send::<super::Error>();
+    crate::test_utils::assert_sync::<super::Error>();
+  }
+}

+ 1 - 1
core/tauri/src/ipc/authority.rs

@@ -363,7 +363,7 @@ pub struct ScopeManager {
 /// though this is useful if you need to do some initialization logic on the type itself.
 pub trait ScopeObject: Sized + Send + Sync + Debug + 'static {
   /// The error type.
-  type Error: std::error::Error + Send;
+  type Error: std::error::Error + Send + Sync;
   /// Deserialize the raw scope value.
   fn deserialize<R: Runtime>(app: &AppHandle<R>, raw: Value) -> Result<Self, Self::Error>;
 }