{"record":{"id":"017d7fd548976d77","repo":"langflow-ai/langflow","slug":"error-in-streaming-request","errorCode":null,"errorMessage":"Error in streaming request.","messagePattern":"Error in streaming request\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/frontend/src/controllers/API/api.tsx","lineNumber":347,"sourceCode":"  const params: RequestInit = {\n    method: method,\n    headers: headers,\n    signal: buildController.signal,\n    credentials: getFetchCredentials(),\n  };\n  if (body) {\n    params.body = JSON.stringify(body);\n  }\n  let current: string[] = [];\n  const textDecoder = new TextDecoder();\n\n  try {\n    const response = await fetch(url, params);\n    if (!response.ok) {\n      if (onError) {\n        onError(response.status);\n      } else {\n        throw new Error(\"Error in streaming request.\");\n      }\n    }\n    if (response.body === null) {\n      return;\n    }\n    const reader = response.body.getReader();\n    while (true) {\n      const { done, value } = await reader.read();\n      if (done) {\n        break;\n      }\n      const decodedChunk = textDecoder.decode(value);\n      const all = decodedChunk.split(\"\\n\\n\");\n\n      // Parse all complete events from this chunk first\n      const parsedEvents: object[] = [];\n      for (const string of all) {\n        if (string.endsWith(\"}\")) {","sourceCodeStart":329,"sourceCodeEnd":365,"githubUrl":"https://github.com/langflow-ai/langflow/blob/976ec789d2886a86de109c044d089d68e96c9a35/src/frontend/src/controllers/API/api.tsx#L329-L365","documentation":"Thrown by performStreamingRequest in controllers/API when the fetch for a streaming endpoint returns a non-OK response and no onError callback was supplied. The helper delegates status handling to onError; without it, all it can do is raise this generic error, and the stream is never read.","triggerScenarios":"Calling performStreamingRequest({url, ...}) where url returns 4xx/5xx and the options object omits onError — e.g. an SSE/build/chat endpoint returning 401 after token expiry or 404 for a missing resource.","commonSituations":"New call sites forgetting the onError parameter; expired sessions hitting stream endpoints; endpoints returning 404 after a route rename in a newer backend.","solutions":["Pass an onError callback so callers receive the real status code instead of a generic throw","Check devtools for the actual status of the failing stream request and fix the underlying cause (auth, 404, 500)","If 401/403, refresh the session and retry once","Verify the URL and payload shape match the current backend version after upgrades"],"exampleFix":"// before\nawait performStreamingRequest({ method: \"POST\", url, body });\n\n// after\nawait performStreamingRequest({\n  method: \"POST\",\n  url,\n  body,\n  onError: (status) => {\n    if (status === 401) refreshSession();\n    else setStreamError(`Stream failed with ${status}`);\n  },\n});","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await performStreamingRequest({ method, url, body, onError: (status) => {\n    streamErrors.push(status); // always pass onError; the generic throw is the no-onError fallback\n  }});\n} catch (e) {\n  if (e instanceof Error && e.message === \"Error in streaming request.\") {\n    // no onError was wired; add one to learn the real status\n  } else throw e;\n}","preventionTips":["Always pass an onError callback to performStreamingRequest","Handle 401 with a session refresh and one retry","Validate the URL/payload against the current backend API version before streaming"],"tags":["frontend","streaming","http-error","api-client"],"backgroundTag":null,"analyzedSha":"976ec789d2886a86de109c044d089d68e96c9a35","analyzedAt":"2026-08-14T18:23:12.227Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}