Relaunch ComfyUI when a process is up but the API never becomes ready.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Towsty
2026-08-25 19:40:52 -05:00
co-authored by Cursor
parent f5829995c8
commit 1a271c05a4
2 changed files with 18 additions and 15 deletions
-1
View File
@@ -67,7 +67,6 @@ const server = http.createServer(async (req, res) => {
}
if (req.method === 'POST' && url.pathname === '/start') {
if (await httpUp()) return json(res, 200, { ok: true, started: false, already: true })
if (await processUp()) return json(res, 200, { ok: true, started: false, booting: true })
const launched = startComfy()
return json(res, 200, { ok: true, ...launched })
}
+10 -6
View File
@@ -223,23 +223,27 @@ async function ensureUnlocked(onStatus: StatusFn) {
processRunning: true
})
const ready = await pollUntilHealthy(cfg.bootPollAttempts, cfg.bootPollDelayMs, onStatus, 'booting', 'Waiting for ComfyUI to finish booting')
if (!ready) {
throw createError({
statusCode: 503,
statusMessage: 'ComfyUI is running but port 8188 never became ready. Check the desktop instance.'
})
}
if (ready) {
await waitWhileBusy(onStatus)
onStatus({ state: 'online', message: 'ComfyUI online', host, processRunning: true })
return
}
onStatus({
state: 'starting',
message: 'ComfyUI is running but the API never came up. Attempting a relaunch...',
host,
processRunning: true
})
}
if (!running) {
onStatus({
state: 'starting',
message: 'ComfyUI is offline. Starting the desktop instance...',
host,
processRunning: false
})
}
const started = await startComfy()
if (!started.started) {
throw createError({