{"record":{"id":"523bd859db7064ca","repo":"continuedev/continue","slug":"error-streaming-response-json-stringify-data-er","errorCode":null,"errorMessage":"Error streaming response: ${JSON.stringify(data.error)}","messagePattern":"Error streaming response: (.+?)","errorType":"error_code","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/fetch/src/stream.ts","lineNumber":92,"sourceCode":"\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  }\n}\n","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/continuedev/continue/blob/5522c6f44ca0ac3528b37244818fbfa39b5af470/packages/fetch/src/stream.ts#L74-L110","documentation":"Same as the message variant: the streamed data line contained an error object without a 'message' property, so the whole error is JSON.stringify'd into the exception text.","triggerScenarios":"Stream data line has {error: ...} where error is not an object with 'message' (string, array, or object without message).","commonSituations":"Non-standard provider error payloads, proxies returning {error: 'gateway timeout'}, or partial JSON error shapes.","solutions":["Log the stringified error to identify the upstream shape","Match on /^Error streaming response:/ in catch blocks regardless of which variant threw","Fix the upstream/proxy producing non-standard error payloads","Retry if the stringified error indicates transient conditions"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"catch (e) { if (/^Error streaming response:/.test(e.message)) { const payload = e.message.replace(/^Error streaming response: /, ''); const parsed = JSON.parse(payload); /* non-standard error shape */ } }","preventionTips":["Don't assume error.message is the provider text — it may be JSON","Log raw in-stream errors to identify non-standard upstream shapes","Test against your actual provider's error payloads"],"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"}