diff --git a/tauri/src/app/utils.rs b/tauri/src/app/utils.rs index d95c61b30..49679e9ec 100644 --- a/tauri/src/app/utils.rs +++ b/tauri/src/app/utils.rs @@ -339,9 +339,20 @@ async fn on_message( Err(e) => Err(e), }; if let Err(crate::Error::UnknownApi(_)) = response { - response = crate::plugin::extend_api(A::plugin_store(), &webview_manager, &message.inner) - .await - .map(|value| value.into()); + match crate::plugin::extend_api(A::plugin_store(), &webview_manager, &message.inner).await { + Ok(value) => { + // If value is None, that means that no plugin matched the command + // and the UnknownApi error should be sent to the webview + // Otherwise, send the result of plugin handler + if value.is_some() { + response = Ok(value.into()); + } + } + Err(e) => { + // A plugin handler was found but it failed + response = Err(e); + } + } } response };