moeru-ai/airi · error · Error
ComfyUI disconnected during polling: ${e.message}
Error message
ComfyUI disconnected during polling: ${e.message} What it means
Thrown by the ComfyUI provider when fetchWithTimeout to <serverUrl>/history/{promptId} throws a network-level error during the polling loop. Unlike a non-ok response, this means the fetch itself failed (connection dropped, DNS, timeout) and the provider treats mid-poll disconnection as fatal.
Source
Thrown at apps/stage-tamagotchi/src/main/services/airi/widgets/providers/comfyui.ts:182
while (!historyDone) {
await new Promise(r => setTimeout(r, POLL_INTERVAL_MS))
attempt++
if (Date.now() - startTime > POLL_TIMEOUT_MS) {
throw new Error('Generation timed out after 5 minutes')
}
if (attempt % 3 === 0) {
log.log(`[ComfyUI] Polling history for ${promptId}... attempt ${attempt}`)
}
let histResp: Response
try {
histResp = await this.fetchWithTimeout(`${this.serverUrl}/history/${promptId}`, {}, 10000)
}
catch (e: any) {
throw new Error(`ComfyUI disconnected during polling: ${e.message}`)
}
if (histResp.ok) {
const histData = await histResp.json()
if (histData[promptId]) {
let outputs = histData[promptId].outputs
const stats = histData[promptId].status
// 3.1. Race condition protection: If outputs are missing, wait a beat and retry once
if ((!outputs || Object.keys(outputs).length === 0) && !historyDone) {
log.warn(`[ComfyUI] Job ${jobId} finished but outputs are empty. Retrying history in 1s...`)
await new Promise(r => setTimeout(r, 1000))
const retryResp = await this.fetchWithTimeout(`${this.serverUrl}/history/${promptId}`, {}, 10000)
if (retryResp.ok) {
const retryData = await retryResp.json()
if (retryData[promptId] && retryData[promptId].outputs) {
log.log(`[ComfyUI] Retry successful for ${jobId}. Managed to find outputs!`)
outputs = retryData[promptId].outputsView on GitHub (pinned to 27111382b4)
Solutions
- Verify ComfyUI is still running and reachable at serverUrl when the error occurs.
- If the disconnection is transient, add retry logic around the history fetch instead of failing immediately.
- Raise the history fetchWithTimeout (10000ms) if ComfyUI is slow to respond under load.
- Stabilize the network path to the ComfyUI host (wired connection, fixed host).
Defensive patterns
Strategy: retry
Try / catch
try {
return await provider.generate(request)
} catch (e) {
if (/disconnected during polling/.test(errorMessageFrom(e) ?? '')) {
// optionally wait and retry once if the drop looks transient
await new Promise(r => setTimeout(r, 2000))
return await provider.generate(request)
}
throw e
} Prevention
- Add bounded retry around the history fetch for transient network drops.
- Keep the ComfyUI host on a stable, low-latency connection.
- Raise the 10s history fetchWithTimeout if the host is occasionally slow.
When it happens
Trigger: During the polling loop the connection to ComfyUI is lost — the server crashed, network dropped, the 10-second fetchWithTimeout elapsed (server hung), or a transient network blip interrupted the history fetch.
Common situations: ComfyUI process restarted/crashed mid-generation; Wi-Fi/VPN flapped; the ComfyUI host is overloaded and stops responding within the 10s history timeout; a proxy/load balancer cut an idle connection.
Related errors
- Cannot connect to ComfyUI at ${this.serverUrl}: ${e.message}
- HTTP ${resp.status}
- Generation timed out after 5 minutes
- ComfyUI upload failed: ${error}
- Failed to fetch image: ${response.statusText}
AI-assisted analysis of moeru-ai/airi@27111382b4 (2026-08-12).
Data as JSON: /api/errors/e181f5dec9225517.
Report an issue: GitHub.