janhq/jan · error · MlxError

MlxError , message: " " }}

Error message

MlxError {{ code: {code:?}, message: "{message}" }}

What it means

MlxError is the structured error type of the tauri-plugin-mlx plugin: it pairs an ErrorCode enum (e.g. MlxProcessError, IoError, InternalError) with a human-readable message and optional details. It is thrown when MLX-side operations fail — spawning/communicating with the MLX process, filesystem IO, or internal plugin failures. Its Display renders code and message, and it serializes to the frontend including optional details.

Solutions

  1. Read `code` and `message`/`details` on the error to identify the failing subsystem before changing code.
  2. If code is MlxProcessError: check that the MLX runtime/binary exists and runs, and inspect its stderr output.
  3. If code is IoError: verify model paths and file permissions.
  4. If code is InternalError: update the plugin and report with the captured details string.

Example fix

// before: string-matching the Display output
if err.to_string().contains("process") { restart(); }

// after: match on the structured code
match mlx_err.code {
    ErrorCode::MlxProcessError => restart_mlx_process(),
    ErrorCode::IoError => validate_model_path(),
    ErrorCode::InternalError => log_and_report(mlx_err.details),
}
Defensive patterns

Strategy: try-catch

Type guard

// Rust: narrow to the structured plugin error
fn as_mlx_error(err: &ServerError) -> Option<&MlxError> {
    match err { ServerError::Mlx(m) => Some(m), _ => None }
}

Try / catch

match mlx_operation() {
    Err(ServerError::Mlx(m)) => match m.code {
        ErrorCode::MlxProcessError => restart_mlx(),
        ErrorCode::IoError => check_paths(),
        ErrorCode::InternalError => report_bug(&m.details),
    },
    Err(e) => forward(e),
    Ok(v) => use(v),
}

Prevention

When it happens

Trigger: Any MLX plugin API call (model load, generate, server start) where the underlying MLX process errors, an IO operation fails, or the plugin hits an internal error; constructed with the corresponding ErrorCode variant.

Common situations: MLX binary missing or crashing; model path wrong or unreadable; insufficient memory on Apple Silicon; invalid generation parameters passed from the frontend.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


AI-assisted analysis of janhq/jan@7205d770c1 (2026-09-17). Data as JSON: /api/errors/b8772d3e7645921e. Report an issue: GitHub.

Appendix: source

Thrown at src-tauri/plugins/tauri-plugin-mlx/src/error.rs:17

use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum ErrorCode {
    BinaryNotFound,
    ModelFileNotFound,
    ModelLoadFailed,
    ModelLoadTimedOut,
    OutOfMemory,
    MlxProcessError,
    IoError,
    InternalError,
}

#[derive(Debug, Clone, Serialize, thiserror::Error)]
#[error("MlxError {{ code: {code:?}, message: \"{message}\" }}")]
pub struct MlxError {
    pub code: ErrorCode,
    pub message: String,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub details: Option<String>,
}

impl MlxError {
    pub fn new(code: ErrorCode, message: String, details: Option<String>) -> Self {
        Self {
            code,
            message,
            details,
        }
    }

    /// Parses stderr from the MLX server and creates a specific MlxError.
    pub fn from_stderr(stderr: &str) -> Self {

View on GitHub (pinned to 7205d770c1)