{"record":{"id":"9c16c01a4d99bd53","repo":"janhq/jan","slug":"response-body-is-null","errorCode":null,"errorMessage":"Response body is null","messagePattern":"Response body is null","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"extensions/llamacpp-extension/src/index.ts","lineNumber":2430,"sourceCode":"    }\n    const response = await fetch(url, {\n      method: 'POST',\n      headers,\n      body,\n      connectTimeout: Number(this.timeout) * 1000, // default 10 minutes\n      signal: combinedController.signal,\n    }).finally(() => clearTimeout(timeoutId))\n    if (!response.ok) {\n      const errorData = await response.json().catch(() => null)\n      throw new Error(\n        `API request failed with status ${response.status}: ${JSON.stringify(\n          errorData\n        )}`\n      )\n    }\n\n    if (!response.body) {\n      throw new Error('Response body is null')\n    }\n\n    const reader = response.body.getReader()\n    const decoder = new TextDecoder('utf-8')\n    let buffer = ''\n    let jsonStr = ''\n    try {\n      while (true) {\n        const { done, value } = await reader.read()\n\n        if (done) {\n          break\n        }\n\n        buffer += decoder.decode(value, { stream: true })\n\n        // Process complete lines in the buffer\n        const lines = buffer.split('\\n')","sourceCodeStart":2412,"sourceCodeEnd":2448,"githubUrl":"https://github.com/janhq/jan/blob/7205d770c1e097c3daf35a911176410e93bc5564/extensions/llamacpp-extension/src/index.ts#L2412-L2448","documentation":"Thrown after the HTTP status check succeeds when the Response object has a null body, so the streaming reader cannot be created. In practice this means the runtime handed back a response with no readable stream, and the extension cannot iterate SSE chunks.","triggerScenarios":"A 2xx response whose body is null — typically from an unusual fetch polyfill/environment, an empty-body response from a proxy, or a runtime quirk in the host app's fetch implementation.","commonSituations":"Running inside an environment with a non-standard fetch (older polyfills, custom adapters in Node/Tauri hosts); middleware or proxies stripping the body on 204/empty responses.","solutions":["Check the response status/headers upstream — a null body with 200 usually means a proxy or adapter issue.","Ensure you use the platform's standard fetch implementation (not an old polyfill) in the extension host.","Retry the request; transient proxy failures can produce empty bodies.","If it persists, log response.status and headers to identify which layer returned the empty response."],"exampleFix":"// before\nconst reader = response.body.getReader()\n// after\nif (!response.body) {\n  throw new Error('Response body is null')\n}\nconst reader = response.body.getReader()","handlingStrategy":"retry","validationCode":"null","typeGuard":"function hasBody(res: Response): res is Response & { body: ReadableStream } {\n  return res.body != null\n}","tryCatchPattern":"let res = await fetch(url, init)\nif (res.ok && !res.body) {\n  res = await fetch(url, init) // retry once on empty body\n}\nif (!res.body) throw new Error('Empty response body after retry')","preventionTips":["Use the platform's native fetch, not legacy polyfills.","Avoid proxies that buffer or strip streaming responses.","Retry once on a null body — often transient middleware behavior.","Log status + headers when the body is null to identify the culprit layer."],"tags":["streaming","http","null","llamacpp"],"backgroundTag":"empty-response-body","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"}