{"record":{"id":"9391f8eb1a95e5c4","repo":"janhq/jan","slug":"error-message-9391f8","errorCode":null,"errorMessage":"error.message","messagePattern":"error\\.message","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"extensions/mlx-extension/src/index.ts","lineNumber":524,"sourceCode":"\n          if (trimmedLine.startsWith('data: ')) {\n            const jsonStr = trimmedLine.slice(6)\n            try {\n              const data = JSON.parse(jsonStr) as chatCompletionChunk\n\n              if (data.choices?.[0]?.finish_reason === 'length') {\n                throw new Error(OUT_OF_CONTEXT_SIZE)\n              }\n\n              yield data\n            } catch (e) {\n              logger.error('Error parsing MLX stream JSON:', e)\n              throw e\n            }\n          } else if (trimmedLine.startsWith('error: ')) {\n            const jsonStr = trimmedLine.slice(7)\n            const error = JSON.parse(jsonStr)\n            throw new Error(error.message)\n          }\n        }\n      }\n    } finally {\n      reader.releaseLock()\n    }\n  }\n\n  override async delete(modelId: string): Promise<void> {\n    const modelDir = await joinPath([\n      await this.getProviderPath(),\n      'models',\n      modelId,\n    ])\n\n    const modelConfigPath = await joinPath([modelDir, 'model.yml'])\n    if (!(await fs.existsSync(modelConfigPath))) {\n      throw new Error(`Model ${modelId} does not exist`)","sourceCodeStart":506,"sourceCodeEnd":542,"githubUrl":"https://github.com/janhq/jan/blob/7205d770c1e097c3daf35a911176410e93bc5564/extensions/mlx-extension/src/index.ts#L506-L542","documentation":"The MLX server can send SSE lines of the form 'error: {json}'; the extension parses the JSON and rethrows its message field verbatim. This is a pass-through of a server-side streaming error, so the text varies (load failure, generation error, out-of-memory, etc.).","triggerScenarios":"During handleStreamingResponse, a streamed line starts with 'error: ' and its JSON contains {message: ...} — the server failed during generation (e.g. model error, memory exhaustion, invalid request detected mid-stream).","commonSituations":"MLX server hitting memory limits while generating, corrupted model weights, incompatibilities between server and extension streaming protocol versions.","solutions":["Read the propagated message for the concrete server-side cause","Check MLX server logs/stderr at the time of the failure","Verify model files are intact (re-download if corrupted)","Update server and extension to matching versions"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"null","typeGuard":"const isSseErrorLine = (line) => line.startsWith('error: ') && (() => { try { return typeof JSON.parse(line.slice(7))?.message === 'string' } catch { return false } })()","tryCatchPattern":"try {\n  for await (const chunk of streamChat(messages, model)) handle(chunk)\n} catch (e) {\n  logger.error('MLX stream error:', e.message)\n  await reloadModel(model.id) // server-side failure: safest recovery is reload\n  throw e\n}","preventionTips":["Capture MLX server stderr alongside the stream for correlation","Reload the model after any mid-stream server error","Keep server/extension versions matched to avoid protocol drift","Verify model file integrity after failed generations"],"tags":["mlx","streaming","sse","server-error"],"backgroundTag":"upstream-api-error","analyzedSha":"7205d770c1e097c3daf35a911176410e93bc5564","analyzedAt":"2026-09-17T14:27:30.100Z","contentChangedAt":"2026-09-17T14:27:30.100Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}