tonhowtf/omniget · warning

Failed to show toast

Error message

Failed to show toast: {}

What it means

PluginHostImpl::show_toast emits a 'plugin-toast' event to the frontend to render a toast notification. If Tauri's emit fails, the error is wrapped with this message including the underlying cause. The user simply never sees the toast.

Solutions

  1. Guard toast emission: check the window/app is still alive before emitting.
  2. Log-and-ignore: toasts are cosmetic, so downgrade this failure to a warning.
  3. Check the wrapped inner error for the actual Tauri cause (window handle invalid, runtime closed).

Example fix

// before
.map_err(|e| anyhow::anyhow!("Failed to show toast: {}", e))
// after
if let Err(e) = self.app.emit("plugin-toast", payload) {
    log::debug!("toast dropped: {e}");
}
Ok(())
Defensive patterns

Strategy: try-catch

Try / catch

if let Err(e) = host.show_toast("info", "done") {
    log::debug!("toast not shown: {e}"); // cosmetic, safe to ignore
}

Prevention

When it happens

Trigger: Calling show_toast when the Tauri event system cannot deliver: window closed, runtime shutting down, or emit serialization failure while a plugin requests a toast.

Common situations: Plugin triggers a toast after the main window was closed; app exit in progress; plugin running on a thread racing app teardown.

Understand the failure class

Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.

Related errors


AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12). Data as JSON: /api/errors/54ecb13a414b6704. Report an issue: GitHub.

Appendix: source

Thrown at src-tauri/src/plugin_host.rs:33

}

impl<R: Runtime + 'static> PluginHost for PluginHostImpl<R> {
    fn emit_event(&self, name: &str, payload: serde_json::Value) -> anyhow::Result<()> {
        self.app
            .emit(name, payload)
            .map_err(|e| anyhow::anyhow!("Failed to emit event '{}': {}", name, e))
    }

    fn show_toast(&self, toast_type: &str, message: &str) -> anyhow::Result<()> {
        self.app
            .emit(
                "plugin-toast",
                serde_json::json!({
                    "type": toast_type,
                    "message": message,
                }),
            )
            .map_err(|e| anyhow::anyhow!("Failed to show toast: {}", e))
    }

    fn plugin_data_dir(&self, plugin_id: &str) -> PathBuf {
        self.plugins_dir.join(plugin_id).join("data")
    }

    fn plugin_frontend_dir(&self, plugin_id: &str) -> PathBuf {
        self.plugins_dir.join(plugin_id).join("frontend")
    }

    fn get_settings(&self, plugin_id: &str) -> serde_json::Value {
        let settings_path = self
            .plugins_dir
            .join(plugin_id)
            .join("data")
            .join("settings.json");
        // Mesmo par lê-default-e-reescreve do registro de cookies: sem a
        // quarentena, um settings.json de plugin corrompido é apagado pelo

View on GitHub (pinned to 8600b91f42)