{"record":{"id":"54ecb13a414b6704","repo":"tonhowtf/omniget","slug":"failed-to-show-toast","errorCode":null,"errorMessage":"Failed to show toast: {}","messagePattern":"Failed to show toast: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src-tauri/src/plugin_host.rs","lineNumber":33,"sourceCode":"}\n\nimpl<R: Runtime + 'static> PluginHost for PluginHostImpl<R> {\n    fn emit_event(&self, name: &str, payload: serde_json::Value) -> anyhow::Result<()> {\n        self.app\n            .emit(name, payload)\n            .map_err(|e| anyhow::anyhow!(\"Failed to emit event '{}': {}\", name, e))\n    }\n\n    fn show_toast(&self, toast_type: &str, message: &str) -> anyhow::Result<()> {\n        self.app\n            .emit(\n                \"plugin-toast\",\n                serde_json::json!({\n                    \"type\": toast_type,\n                    \"message\": message,\n                }),\n            )\n            .map_err(|e| anyhow::anyhow!(\"Failed to show toast: {}\", e))\n    }\n\n    fn plugin_data_dir(&self, plugin_id: &str) -> PathBuf {\n        self.plugins_dir.join(plugin_id).join(\"data\")\n    }\n\n    fn plugin_frontend_dir(&self, plugin_id: &str) -> PathBuf {\n        self.plugins_dir.join(plugin_id).join(\"frontend\")\n    }\n\n    fn get_settings(&self, plugin_id: &str) -> serde_json::Value {\n        let settings_path = self\n            .plugins_dir\n            .join(plugin_id)\n            .join(\"data\")\n            .join(\"settings.json\");\n        // Mesmo par lê-default-e-reescreve do registro de cookies: sem a\n        // quarentena, um settings.json de plugin corrompido é apagado pelo","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/src/plugin_host.rs#L15-L51","documentation":"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.","triggerScenarios":"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.","commonSituations":"Plugin triggers a toast after the main window was closed; app exit in progress; plugin running on a thread racing app teardown.","solutions":["Guard toast emission: check the window/app is still alive before emitting.","Log-and-ignore: toasts are cosmetic, so downgrade this failure to a warning.","Check the wrapped inner error for the actual Tauri cause (window handle invalid, runtime closed)."],"exampleFix":"// before\n.map_err(|e| anyhow::anyhow!(\"Failed to show toast: {}\", e))\n// after\nif let Err(e) = self.app.emit(\"plugin-toast\", payload) {\n    log::debug!(\"toast dropped: {e}\");\n}\nOk(())","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if let Err(e) = host.show_toast(\"info\", \"done\") {\n    log::debug!(\"toast not shown: {e}\"); // cosmetic, safe to ignore\n}","preventionTips":["Treat toast failures as non-fatal and log them","Avoid toasting after window close/exit begins","Check window liveness before emitting UI events"],"tags":["tauri","toast","event-emission","plugin-host"],"backgroundTag":"http-error-response","analyzedSha":"8600b91f4246848bac346874daa9e61c1fc5677a","analyzedAt":"2026-09-12T14:29:19.317Z","contentChangedAt":"2026-09-12T14:29:19.317Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}