{"record":{"id":"f1429311559acddc","repo":"libnyanpasu/clash-nyanpasu","slug":"error-while-running-tauri-application","errorCode":null,"errorMessage":"error while running tauri application","messagePattern":"error while running tauri application","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"backend/tauri/src/lib.rs","lineNumber":341,"sourceCode":"                    log_err!(\n                        crate::ipc::SchemeRequestReceivedEvent { url: request }.emit(&handle),\n                        \"failed to emit scheme-request-received event\"\n                    );\n                }\n            ));\n            std::thread::spawn(move || {\n                nyanpasu_utils::runtime::block_on(async move {\n                    server::run(*server::SERVER_PORT)\n                        .await\n                        .expect(\"failed to start server\");\n                });\n            });\n            Ok(())\n        });\n\n    let app = builder\n        .build(tauri::generate_context!())\n        .expect(\"error while running tauri application\");\n    app.run(|app_handle, e| match e {\n        tauri::RunEvent::ExitRequested { api, code, .. } if code.is_none() => {\n            api.prevent_exit();\n        }\n        tauri::RunEvent::ExitRequested { .. } => {\n            utils::help::cleanup_processes(app_handle);\n        }\n        tauri::RunEvent::WindowEvent { label, event, .. } if label == \"main\" => match event {\n            tauri::WindowEvent::ScaleFactorChanged { scale_factor, .. } => {\n                core::tray::on_scale_factor_changed(scale_factor);\n            }\n            tauri::WindowEvent::CloseRequested { .. } => {\n                log::debug!(target: \"app\", \"window close requested\");\n                let _ = resolve::save_window_state(app_handle, true);\n                #[cfg(target_os = \"macos\")]\n                crate::utils::dock::macos::hide_dock_icon();\n            }\n            tauri::WindowEvent::Destroyed => {","sourceCodeStart":323,"sourceCodeEnd":359,"githubUrl":"https://github.com/libnyanpasu/clash-nyanpasu/blob/f7dbce2997c633e484f54788035e770b3ee99773/backend/tauri/src/lib.rs#L323-L359","documentation":"builder.build(tauri::generate_context!()) constructs the Tauri application; any error there is unwrapped with .expect('error while running tauri application'). This covers failures building the app context — invalid/missing tauri.conf.json values, missing icons/resources, window creation failures, or plugin registration errors.","triggerScenarios":"Invalid tauri.conf.json (bad identifier, missing frontendDist, bad window config); missing icon files referenced by the config; a plugin's initialization failing during build; generate_context embedding failing on this platform.","commonSituations":"Running a debug build where the frontend dist folder is empty/missing; upgrading Tauri versions with breaking config schema changes; corrupted or missing bundled resources/icons; duplicate plugin registration.","solutions":["Validate tauri.conf.json against the current Tauri schema and fix invalid fields","Ensure the frontend dist output (frontendDist) exists — run the frontend build before cargo build","Check all icons/resources referenced by the config exist","Update/align plugin versions with the Tauri version and fix plugin init errors surfaced in the panic chain"],"exampleFix":"// diagnose instead of opaque panic\nlet app = builder.build(tauri::generate_context!())\n    .unwrap_or_else(|e| {\n        eprintln!(\"tauri build failed: {e:?}\");\n        std::process::exit(1);\n    });","handlingStrategy":"try-catch","validationCode":"// before building: verify frontendDist exists and config is loadable\nassert!(std::path::Path::new(\"dist/index.html\").exists(), \"frontend dist missing\");","typeGuard":null,"tryCatchPattern":"let app = builder.build(tauri::generate_context!()).unwrap_or_else(|e| {\n    eprintln!(\"tauri init failed: {e:?}\");\n    std::process::exit(1);\n});","preventionTips":["Build the frontend before cargo build so frontendDist is populated","Keep tauri.conf.json schema in sync with the Tauri version","Verify icons/resources referenced in config exist in CI"],"tags":["tauri","startup","configuration","panic"],"backgroundTag":"module-init-failed","analyzedSha":"f7dbce2997c633e484f54788035e770b3ee99773","analyzedAt":"2026-09-08T01:24:59.197Z","contentChangedAt":"2026-09-08T01:24:59.197Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}