{"record":{"id":"e86eaf9cc009b13e","repo":"moeru-ai/airi","slug":"generation-failed","errorCode":null,"errorMessage":"Generation failed","messagePattern":"Generation failed","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/stage-tamagotchi/src/main/services/airi/widgets/artistry-bridge.ts","lineNumber":213,"sourceCode":"          log.error(`[Headless] Job ${job.jobId} timed out after 5 minutes.`)\n          throw new Error('Image generation timed out after 5 minutes.')\n        }\n\n        log.log(`[Headless] Polling status for job: ${job.jobId}...`)\n        lastStatus = await provider.getStatus(job.jobId)\n        log.log(`[Headless] Status for job ${job.jobId}: ${lastStatus.status}`)\n\n        if (lastStatus.status === 'succeeded' || lastStatus.status === 'failed') {\n          isDone = true\n        }\n        if (!isDone) {\n          await new Promise(resolve => setTimeout(resolve, 2000))\n        }\n      }\n\n      if (lastStatus.status === 'failed') {\n        log.error(`[Headless] Job ${job.jobId} failed: ${lastStatus.error || 'Unknown error'}`)\n        throw new Error(lastStatus.error || 'Generation failed')\n      }\n\n      log.log(`[Headless] Job ${job.jobId} succeeded. Image URL: ${lastStatus.imageUrl}`)\n      const base64 = lastStatus.imageUrl ? await downloadImageAsBase64(lastStatus.imageUrl) : undefined\n      return { imageUrl: lastStatus.imageUrl, base64 }\n    }\n    else {\n      // For providers with callbacks (like ComfyUI), we wait for the result via the callback\n      log.log(`[Headless] Using callback-based wait logic for provider: ${requestedProvider}`)\n      return new Promise<{ imageUrl?: string, base64?: string }>((resolve, reject) => {\n        const timeout = 1000 * 60 * 5 // 5 minutes timeout\n        const timer = setTimeout(() => {\n          reject(new Error('Image generation timed out after 5 minutes.'))\n        }, timeout)\n\n        provider.setJobCallback(request.extra?.internalJobId as string, async (status) => {\n          if (status.status === 'succeeded') {\n            clearTimeout(timer)","sourceCodeStart":195,"sourceCodeEnd":231,"githubUrl":"https://github.com/moeru-ai/airi/blob/27111382b4a79a7e983289d6e983a06af185ed0f/apps/stage-tamagotchi/src/main/services/airi/widgets/artistry-bridge.ts#L195-L231","documentation":"Thrown by generateHeadless when the polling loop receives a terminal 'failed' status from provider.getStatus. If lastStatus.error is present its value is used as the message, otherwise the generic 'Generation failed' is thrown. This is the provider reporting that the image job itself failed, not a transport error.","triggerScenarios":"The provider backend accepted the job and started it, but the generation later failed — e.g. model load error, out-of-memory on the GPU, invalid prompt/workflow, content filter rejection, or an internal backend exception surfaced through getStatus.error.","commonSituations":"ComfyUI ran out of VRAM mid-generation; the workflow JSON referenced a missing node/model; an API provider rejected the prompt for policy reasons; the model crashed; an invalid resolution was requested.","solutions":["Read lastStatus.error from the logs to get the backend-specific failure reason and address it (free VRAM, fix workflow, adjust prompt).","Retry the generation after the backend recovers or with simpler parameters.","Validate prompt/resolution inputs before submission to avoid backend rejections.","For ComfyUI, verify the workflow template and referenced checkpoints are installed."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  return await generateHeadless(params)\n} catch (e) {\n  const msg = errorMessageFrom(e) ?? ''\n  if (/generation failed/i.test(msg) || /failed$/i.test(msg)) {\n    return { error: `Image generation failed: ${msg}` }\n  }\n  throw e\n}","preventionTips":["Surface lastStatus.error to the user so they can correct the prompt/workflow.","Validate prompt/resolution against provider constraints before submission.","Keep backend models/checkpoints installed so generation doesn't fail mid-run."],"tags":["artistry","generation","providers","gpu"],"backgroundTag":null,"analyzedSha":"27111382b4a79a7e983289d6e983a06af185ed0f","analyzedAt":"2026-08-12T18:33:34.132Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}