{"record":{"id":"f6f834ab184e1099","repo":"flipped-aurora/gin-vue-admin","slug":"llm-stream-request-timed-out","errorCode":null,"errorMessage":"LLM stream request timed out","messagePattern":"LLM stream request timed out","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"web/src/api/autoCode.js","lineNumber":234,"sourceCode":"    if (buffer.trim()) {\n      const trimmed = buffer.trim()\n      if (trimmed.startsWith('data:')) {\n        const dataStr = trimmed.slice(5).trim()\n        if (dataStr && dataStr !== '[DONE]') {\n          try {\n            const event = JSON.parse(dataStr)\n            handleSSEEvent(event)\n          } catch {\n            state.answerText += dataStr\n          }\n        }\n      }\n    }\n\n    return buildLLMStreamResult(state)\n  } catch (error) {\n    if (controller.signal.aborted && timeoutTriggered) {\n      throw new Error('LLM stream request timed out')\n    }\n    throw error\n  } finally {\n    if (timeoutId) timerHost.clearTimeout(timeoutId)\n  }\n}\n\n// 通用 SSE 流式请求导出\nexport const llmAutoSSEStream = (data, options = {}) =>\n  streamLLMRequest(LLM_AUTO_SSE_URL, data, options)\n\n// picture 页专用：预设 mode 为 newCreateWeb\nexport const createWebStream = (data, options = {}) =>\n  llmAutoSSEStream({ mode: 'newCreateWeb', ...data }, options)\n\nexport const preview = (data) => {\n  return service({\n    url: '/autoCode/preview',","sourceCodeStart":216,"sourceCodeEnd":252,"githubUrl":"https://github.com/flipped-aurora/gin-vue-admin/blob/3136500ef380842b0eb6c4daa87c3f8a47fcf9e0/web/src/api/autoCode.js#L216-L252","documentation":"streamLLMRequest wraps the whole stream consumption in a timeout via AbortController. If the timeout fires and the fetch is aborted, the resulting AbortError is replaced with a clearer 'LLM stream request timed out' error.","triggerScenarios":"The LLM stream takes longer than the configured timeout (options.timeout / default) with no completion; fetch rejects with AbortError while timeoutTriggered is true.","commonSituations":"LLM provider is slow or hung generating a long answer; upstream network stall; timeout set too low for long code-generation responses.","solutions":["Increase the timeout value passed to streamLLMRequest/llmAutoSSEStream for long generations","Check upstream LLM provider latency/health","Verify the backend proxy streams chunks promptly instead of buffering until completion","Implement resumable/retry logic so partial output is preserved"],"exampleFix":"// before\nstreamLLMRequest(url, { prompt })\n// after\nstreamLLMRequest(url, { prompt, timeout: 300000 }) // 5min for long generations","handlingStrategy":"retry","validationCode":"const TIMEOUT_MS = 300000\nif ((options.timeout ?? TIMEOUT_MS) < 60000) {\n  console.warn('Timeout below 60s may abort long LLM generations')\n}","typeGuard":"function isTimeoutError(err, timeoutFlagRef) {\n  return timeoutFlagRef.timeoutTriggered && err.name === 'AbortError'\n}","tryCatchPattern":"try {\n  return await streamLLMRequest(url, { ...options, timeout: 300000 })\n} catch (e) {\n  if (e.message === 'LLM stream request timed out') {\n    return retryWithBackoff(() => streamLLMRequest(url, options), 2)\n  }\n  throw e\n}","preventionTips":["Set timeouts relative to expected generation length (long code output needs minutes)","Surface partial state.answerText to the user on timeout instead of discarding it","Monitor upstream LLM provider latency"],"tags":["timeout","streaming","sse","llm","network"],"backgroundTag":"request-timeout","analyzedSha":"3136500ef380842b0eb6c4daa87c3f8a47fcf9e0","analyzedAt":"2026-08-31T13:50:02.721Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}