janhq/jan · warning · Error
No active MLX session found for model: ${modelId}
Error message
No active MLX session found for model: ${modelId} What it means
Thrown by unload() when findSessionByModel(modelId) returns nothing — there is no active MLX session for that id, so there is nothing to stop. The extension does not silently no-op; it errors so callers know the model wasn't loaded. Note findSessionByModel itself throws on plugin errors (a different path).
Source
Thrown at extensions/mlx-extension/src/index.ts:325
modelId,
modelPath,
port,
mlxConfig,
envs,
isEmbedding,
Number(this.timeout)
)
return sInfo
} catch (error) {
logger.error(`Error loading MLX model: ${JSON.stringify(error)}`)
throw error
}
}
override async unload(modelId: string): Promise<UnloadResult> {
const sInfo = await this.findSessionByModel(modelId)
if (!sInfo) {
throw new Error(`No active MLX session found for model: ${modelId}`)
}
try {
const result = await unloadMlxModel(sInfo.pid)
if (result.success) {
logger.info(`Successfully unloaded MLX model with PID ${sInfo.pid}`)
} else {
logger.warn(`Failed to unload MLX model: ${result.error}`)
}
return result
} catch (error) {
logger.error('Error unloading MLX model:', error)
return {
success: false,
error: `Failed to unload model: ${error}`,
}
}
}View on GitHub (pinned to fad3f12a14)
Solutions
- Guard unload calls with findSessionByModel (or getLoadedModels) and skip if absent.
- Treat 'not loaded' as a no-op success in cleanup paths rather than an error.
- Verify the modelId string matches the id used at load() time.
Example fix
// before
await engine.unload(modelId)
// after
const sInfo = await engine.findSessionByModel(modelId).catch(() => null)
if (!sInfo) return { success: true } // nothing to unload
await engine.unload(modelId) Defensive patterns
Strategy: validation
Validate before calling
const sInfo = await engine.findSessionByModel(modelId).catch(() => null)
if (!sInfo) return { success: true } // not loaded; treat as no-op
await engine.unload(modelId) Try / catch
try {
await engine.unload(modelId)
} catch (e) {
if (/No active MLX session/.test(String(e))) return { success: true }
throw e
} Prevention
- Guard all cleanup-path unload calls with a session existence check.
- Make 'not loaded' a no-op success in shutdown logic.
- Match modelId casing/format to the loaded id.
When it happens
Trigger: Calling engine.unload(modelId) when the model was never loaded, was already unloaded, or crashed and its session entry was already purged; calling unload with a modelId that differs in casing/format from the loaded one.
Common situations: Cleanup/shutdown code unconditionally unloading all models; a user clicks 'stop' on a model that already crashed and was auto-unloaded; retry logic that re-issues unload after a prior success.
Related errors
- Model already loaded!
- No active MLX session found for model: ${opts.model}
- No active session found for model: ${modelId}
- MLX model appears to have crashed! Please reload!
- MLX model has crashed! Please reload!
AI-assisted analysis of janhq/jan@fad3f12a14 (2026-08-12).
Data as JSON: /api/errors/7232227f65ec0537.
Report an issue: GitHub.