Recover finished Comfy videos after relay restarts.
Persist queued jobs to disk, import leftover MP4s from Comfy history, and do not mark a run complete until the saved video exists. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,8 +1,23 @@
|
||||
export default defineEventHandler((event) => {
|
||||
export default defineEventHandler(async (event) => {
|
||||
const id = getRouterParam(event, 'id')
|
||||
const job = id ? getJob(id) : undefined
|
||||
if (!job) {
|
||||
throw createError({ statusCode: 404, statusMessage: 'Job not found' })
|
||||
const live = id ? getJob(id) : undefined
|
||||
if (live) return jobSnapshot(live)
|
||||
|
||||
if (id) {
|
||||
const pending = readPendingJob(id)
|
||||
if (pending) {
|
||||
const done = await completePendingIfReady(pending).catch(() => null)
|
||||
if (done) return done
|
||||
return {
|
||||
type: 'snapshot',
|
||||
status: 'running',
|
||||
message: 'Reconnecting to ComfyUI...',
|
||||
progress: 90,
|
||||
promptId: pending.promptId,
|
||||
elapsedMs: Date.now() - pending.startedAt
|
||||
}
|
||||
}
|
||||
}
|
||||
return jobSnapshot(job)
|
||||
|
||||
throw createError({ statusCode: 404, statusMessage: 'Job not found' })
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user