flipped-aurora/gin-vue-admin · error · Error
LLM stream request timed out
Error message
LLM stream request timed out
What it means
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.
Source
Thrown at web/src/api/autoCode.js:234
if (buffer.trim()) {
const trimmed = buffer.trim()
if (trimmed.startsWith('data:')) {
const dataStr = trimmed.slice(5).trim()
if (dataStr && dataStr !== '[DONE]') {
try {
const event = JSON.parse(dataStr)
handleSSEEvent(event)
} catch {
state.answerText += dataStr
}
}
}
}
return buildLLMStreamResult(state)
} catch (error) {
if (controller.signal.aborted && timeoutTriggered) {
throw new Error('LLM stream request timed out')
}
throw error
} finally {
if (timeoutId) timerHost.clearTimeout(timeoutId)
}
}
// 通用 SSE 流式请求导出
export const llmAutoSSEStream = (data, options = {}) =>
streamLLMRequest(LLM_AUTO_SSE_URL, data, options)
// picture 页专用:预设 mode 为 newCreateWeb
export const createWebStream = (data, options = {}) =>
llmAutoSSEStream({ mode: 'newCreateWeb', ...data }, options)
export const preview = (data) => {
return service({
url: '/autoCode/preview',View on GitHub (pinned to 3136500ef3)
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
Example fix
// before
streamLLMRequest(url, { prompt })
// after
streamLLMRequest(url, { prompt, timeout: 300000 }) // 5min for long generations Defensive patterns
Strategy: retry
Validate before calling
const TIMEOUT_MS = 300000
if ((options.timeout ?? TIMEOUT_MS) < 60000) {
console.warn('Timeout below 60s may abort long LLM generations')
} Type guard
function isTimeoutError(err, timeoutFlagRef) {
return timeoutFlagRef.timeoutTriggered && err.name === 'AbortError'
} Try / catch
try {
return await streamLLMRequest(url, { ...options, timeout: 300000 })
} catch (e) {
if (e.message === 'LLM stream request timed out') {
return retryWithBackoff(() => streamLLMRequest(url, options), 2)
}
throw e
} Prevention
- 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
When it happens
Trigger: The LLM stream takes longer than the configured timeout (options.timeout / default) with no completion; fetch rejects with AbortError while timeoutTriggered is true.
Common situations: LLM provider is slow or hung generating a long answer; upstream network stall; timeout set too low for long code-generation responses.
Understand the failure class
- Timeouts: ETIMEDOUT, deadlines, and hung requests — what actually expires when a request times out.
Related errors
- LLM stream failed
- 上游大模型流式服务返回非 2xx: status=%d content-type=%s read-body-err=%w
- 向客户端写入流式响应失败: %w
- 读取上游流式响应失败: %w
- 上游大模型流式服务返回非 2xx: status=%d content-type=%s read-body-err=%w
AI-assisted analysis of flipped-aurora/gin-vue-admin@3136500ef3 (2026-08-31).
Data as JSON: /api/errors/f6f834ab184e1099.
Report an issue: GitHub.