{"record":{"id":"8e54d8be06aa35a7","repo":"continuedev/continue","slug":"error-streaming-response-data-error-message","errorCode":null,"errorMessage":"Error streaming response: ${data.error.message}","messagePattern":"Error streaming response: (.+?)","errorType":"error_code","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/fetch/src/stream.ts","lineNumber":90,"sourceCode":"  }\n}\n\n// Export for testing purposes\nexport function parseDataLine(line: string): any {\n  const json = line.startsWith(\"data: \")\n    ? line.slice(\"data: \".length)\n    : line.slice(\"data:\".length);\n\n  try {\n    const data = JSON.parse(json);\n    if (data.error) {\n      if (\n        data.error &&\n        typeof data.error === \"object\" &&\n        \"message\" in data.error\n      ) {\n        console.error(\"Error in streamed response:\", data.error);\n        throw new Error(`Error streaming response: ${data.error.message}`);\n      }\n      throw new Error(\n        `Error streaming response: ${JSON.stringify(data.error)}`,\n      );\n    }\n\n    return data;\n  } catch (e) {\n    // If the error was thrown by our error check, rethrow it\n    if (\n      e instanceof Error &&\n      e.message.startsWith(\"Error streaming response:\")\n    ) {\n      throw e;\n    }\n    // Otherwise it's a JSON parsing error\n    throw new Error(`Malformed JSON sent from server: ${json}`);\n  }","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/continuedev/continue/blob/5522c6f44ca0ac3528b37244818fbfa39b5af470/packages/fetch/src/stream.ts#L72-L108","documentation":"parseDataLine detected an error object in the streamed JSON payload (with a 'message' property) and rethrows it as an Error streaming response error, surfacing the server-side error message from inside the stream.","triggerScenarios":"SSE/JSON stream returns 200 but individual data lines contain {error: {message: ...}} — e.g. provider auth failure or content policy hit occurring after headers were sent.","commonSituations":"LLM APIs that start streaming then fail per-chunk (moderation triggers, token limits, upstream provider errors).","solutions":["Read the embedded message — it's the upstream provider's actual error and dictates the fix","For content-policy/moderation messages, adjust the prompt","For token/rate errors, reduce max_tokens or retry with backoff","Handle per-stream errors so one failed stream doesn't kill the app"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { for await (const c of streamSse(response)) {} } catch (e) { if (e.message.startsWith('Error streaming response:')) { /* provider error inside stream; show message */ } else throw e; }","preventionTips":["Match on the 'Error streaming response:' prefix to distinguish in-stream errors from transport errors","Surface provider messages (moderation, limits) to users","Retry only when the embedded message indicates transient failure"],"tags":["fetch","streaming","sse","provider-error"],"backgroundTag":"in-stream-provider-error","analyzedSha":"5522c6f44ca0ac3528b37244818fbfa39b5af470","analyzedAt":"2026-08-27T11:28:54.683Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}