janhq/jan · error

MLX model has crashed! Please reload!

Error message

MLX model has crashed! Please reload!

What it means

chat() first checks an isAlive flag for the MLX server session; if the session process is already known to be dead, it throws this error immediately without attempting the health fetch. The session is unusable and must be reloaded.

Solutions

  1. Reload the model to start a new MLX server session before retrying
  2. Check system logs (dmesg/journalctl) for OOM kills of the mlx server process
  3. Reduce model size or context length if the server is being OOM-killed
  4. Update the mlx extension/server if crashes are reproducible

Example fix

// before
const res = await chat(messages, model)
// after
let res
try {
  res = await chat(messages, model)
} catch {
  await model.reload()
  res = await chat(messages, model)
}
Defensive patterns

Strategy: try-catch

Validate before calling

if (!sessionInfo.isAlive) {
  await reloadModel(model.id) // proactively reload before chat
}

Type guard

const sessionUsable = (s) => Boolean(s && s.isAlive && s.port)

Try / catch

try {
  return await chat(messages, model)
} catch (e) {
  if (String(e.message).includes('has crashed')) {
    await reloadModel(model.id)
    return chat(messages, model)
  }
  throw e
}

Prevention

When it happens

Trigger: Calling chat() when the MLX server subprocess tracked in sessionInfo has already exited (isAlive === false) — e.g. after a prior crash, manual kill, or abnormal termination.

Common situations: The model was unloaded by the OS OOM killer, the user killed the process, the app was suspended/resumed and the subprocess died, or a previous chat call unloaded the model on failure.

Related errors


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

Appendix: source

Thrown at extensions/mlx-extension/src/index.ts:408

    const sessionInfo = await this.findSessionByModel(opts.model)
    if (!sessionInfo) {
      throw new Error(`No active MLX session found for model: ${opts.model}`)
    }

    // Check if the process is alive
    const isAlive = await invoke<boolean>('plugin:mlx|is_mlx_process_running', {
      pid: sessionInfo.pid,
    })

    if (isAlive) {
      try {
        await fetch(`http://localhost:${sessionInfo.port}/health`)
      } catch (e) {
        this.unload(sessionInfo.model_id)
        throw new Error('MLX model appears to have crashed! Please reload!')
      }
    } else {
      throw new Error('MLX model has crashed! Please reload!')
    }

    const baseUrl = `http://localhost:${sessionInfo.port}/v1`
    const url = `${baseUrl}/chat/completions`
    const headers = {
      'Content-Type': 'application/json',
      'Authorization': `Bearer ${sessionInfo.api_key}`,
    }

    const body = JSON.stringify(opts)

    if (opts.stream) {
      return this.handleStreamingResponse(url, headers, body, abortController)
    }

    const response = await fetch(url, {
      method: 'POST',
      headers,

View on GitHub (pinned to 7205d770c1)