janhq/jan · error · ServerError
Tauri error
Error message
Tauri error: {0} What it means
ServerError::Tauri wraps tauri::Error from command handlers, displayed as "Tauri error: {0}". It is produced via #[from] when Tauri framework operations inside a command (window/app state access, event emission, plugin calls) fail. It keeps framework-level failures distinct from plugin-level LlamacppErrors.
Solutions
- Inspect the wrapped tauri::Error message to see which framework call failed.
- Guard event emissions against missing targets (e.g. get_window returning None).
- Ensure managed state is set up in tauri::Builder::setup before commands access it.
- Avoid calling Tauri APIs after app exit has begun.
Example fix
// before
app.emit("llama-progress", payload)?;
// after
if let Some(w) = app.get_webview_window("main") {
w.emit("llama-progress", payload)?;
} Defensive patterns
Strategy: try-catch
Try / catch
match cmd() {
Err(ServerError::Tauri(e)) => { log::warn!("tauri op failed: {e}"); degrade_gracefully(); }
other => other,
} Prevention
- Check for the target window/webview before emitting events.
- Initialize managed state in Builder::setup before any command runs.
- Avoid Tauri API calls during app shutdown or from detached windows.
When it happens
Trigger: A command uses app state, webview windows, or Tauri APIs that return tauri::Error (e.g. manager access on a torn-down window, failed event emit), auto-converted into ServerError by the #[from] impl.
Common situations: Emitting events to a closed webview, accessing state before setup completes, or invoking Tauri APIs from an invalid app context during shutdown or multi-window scenarios.
Related errors
AI-assisted analysis of janhq/jan@7205d770c1 (2026-09-17).
Data as JSON: /api/errors/24f50005cb7dc6ea.
Report an issue: GitHub.
Appendix: source
Thrown at src-tauri/plugins/tauri-plugin-llamacpp/src/error.rs:202
}
fn push_library(found: &mut Vec<String>, candidate: &str) {
let candidate = candidate.trim_matches(['\'', '"', '(', ')', ',', '.'].as_ref());
if looks_like_library(candidate) && !found.iter().any(|f| f == candidate) {
found.push(candidate.to_string());
}
}
// Error type for server commands
#[derive(Debug, thiserror::Error)]
pub enum ServerError {
#[error(transparent)]
Llamacpp(#[from] LlamacppError),
#[error("IO error: {0}")]
Io(#[from] std::io::Error),
#[error("Tauri error: {0}")]
Tauri(#[from] tauri::Error),
#[error("Invalid argument: {0}")]
InvalidArgument(String),
}
// impl serialization for tauri
impl serde::Serialize for ServerError {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
let error_to_serialize: LlamacppError = match self {
ServerError::Llamacpp(err) => err.clone(),
ServerError::Io(e) => LlamacppError::new(
ErrorCode::IoError,
"An input/output error occurred.".into(),
Some(e.to_string()),View on GitHub (pinned to 7205d770c1)