janhq/jan · error
String(e)
Error message
String(e)
What it means
findSessionByModel wraps the Tauri invoke('plugin:mlx|find_mlx_session_by_model'); on any native-side failure it logs the error and rethrows it as String(e). Callers of load/unload/chat therefore see the raw native error text without a stack trace.
Solutions
- Check logs — the original error is logged before rethrow
- Ensure the Tauri mlx plugin is installed/registered for the current build
- Retry after the app's backend has fully initialized (invoke before ready fails)
- Validate modelId is a non-empty, correctly formatted identifier before lookup
- Update the app if plugin command names changed between versions
Example fix
// before
const s = await mlx.getSessionInfo(modelId)
// after
let s = null
try {
s = await mlx.getSessionInfo(modelId)
} catch (e) {
logger.warn('MLX session lookup failed, treating as not loaded', e)
} Defensive patterns
Strategy: try-catch
Validate before calling
// Guard modelId before native lookup
if (typeof modelId !== 'string' || modelId.trim() === '') {
throw new Error('modelId is required for MLX session lookup')
} Type guard
function hasSessionInfo(v: unknown): v is SessionInfo {
return !!v && typeof v === 'object' && 'pid' in v && typeof (v as SessionInfo).pid === 'number'
} Try / catch
try {
const s = await mlx.getSessionInfo(modelId)
} catch (e) {
logger.warn('MLX session lookup failed; treating as no session', e)
const s = null
} Prevention
- Wait for app/plugin initialization before MLX API calls
- Validate modelId format before invoking native commands
- Check logs for the logged root cause of IPC failures
- Keep the app updated so plugin command names match
When it happens
Trigger: Any session lookup when the Tauri mlx plugin errors — plugin not registered, IPC failure, app backend crashed, or malformed modelId causing a native-side failure.
Common situations: Calling MLX APIs before the app's native plugin layer is ready, after an app update changed plugin commands, or in environments (e.g. web build) where the Tauri IPC is unavailable.
Understand the failure class
Background: "API request failed": what wrapped HTTP errors from external APIs mean and how to find the real cause — this error's family across 29 libraries.
Related errors
AI-assisted analysis of janhq/jan@7205d770c1 (2026-09-17).
Data as JSON: /api/errors/ca60537a3eacc45e.
Report an issue: GitHub.
Appendix: source
Thrown at extensions/mlx-extension/src/index.ts:382
}
return result
} catch (error) {
logger.error('Error unloading MLX model:', error)
return {
success: false,
error: `Failed to unload model: ${error}`,
}
}
}
private async findSessionByModel(modelId: string): Promise<SessionInfo> {
try {
return await invoke<SessionInfo>('plugin:mlx|find_mlx_session_by_model', {
modelId,
})
} catch (e) {
logger.error(e)
throw new Error(String(e))
}
}
override async chat(
opts: chatCompletionRequest,
abortController?: AbortController
): Promise<chatCompletion | AsyncIterable<chatCompletionChunk>> {
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) {View on GitHub (pinned to 7205d770c1)