{"record":{"id":"66f87aac3288a8da","repo":"gitroomhq/postiz-app","slug":"video-generation-timed-out-66f87a","errorCode":null,"errorMessage":"Video generation timed out","messagePattern":"Video generation timed out","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"libraries/nestjs-libraries/src/videos/veo3/veo3.ts","lineNumber":71,"sourceCode":"          prompt: customParams.prompt,\n          imageUrls: customParams?.images?.map((p) => p.path) || [],\n          model: 'veo3_fast',\n          aspectRatio: output === 'horizontal' ? '16:9' : '9:16',\n        }),\n      })\n    ).json();\n\n    if (value.code !== 200 && value.code !== 201) {\n      throw new Error(value?.msg || `Failed to generate video`);\n    }\n\n    const taskId = value.data.taskId;\n    console.log('veo3 taskId', taskId);\n    let attempts = 0;\n    const maxAttempts = 180; // ~30 minutes at 10s interval\n    while (true) {\n      if (attempts++ >= maxAttempts) {\n        throw new Error('Video generation timed out');\n      }\n\n      console.log('waiting for video to be ready');\n      const data = await (\n        await fetch(\n          'https://api.kie.ai/api/v1/veo/record-info?taskId=' + taskId,\n          {\n            headers: {\n              'Content-Type': 'application/json',\n              Authorization: `Bearer ${process.env.KIEAI_API_KEY}`,\n            },\n            signal: AbortSignal.timeout(30000),\n          }\n        )\n      ).json();\n\n      if (data.code !== 200) {\n        throw new Error(data?.msg || `Failed to get video info`);","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/gitroomhq/postiz-app/blob/0f1647f7491a217d43eb5ae7a480484bdf0aff3e/libraries/nestjs-libraries/src/videos/veo3/veo3.ts#L53-L89","documentation":"After successfully creating a veo3 task, the code polls the record-info endpoint every 10 seconds up to 180 times (~30 minutes). If the task never reaches a terminal state within that window, it throws 'Video generation timed out'.","triggerScenarios":"A video generation task stuck in generating state (successFlag 0) for 30+ minutes: long/high-res generations, provider queue backlog, or a task that silently died server-side.","commonSituations":"Peak-hour provider slowness; very long prompts or high resolution; the polling loop's 10s sleep plus API latency stretching past budget; tasks that fail without ever setting a failure flag.","solutions":["Retry the generation — transient provider backlog is the most common cause","Reduce generation complexity (shorter prompt, standard aspect ratio) if it consistently times out","If reproducible, check the taskId directly against kie.ai's API/dashboard to see its real terminal state","Increase maxAttempts or make the whole step resumable via Temporal so it survives long waits instead of blocking a request"],"exampleFix":"// before\nconst maxAttempts = 180; // ~30 minutes\n\n// after (run inside a Temporal activity with retry policy)\nconst maxAttempts = 360; // ~60 min, plus activity retry from workflow\n// and configure: retry: { maximumAttempts: 3 } on the activity options","handlingStrategy":"retry","validationCode":"if (!prompt || prompt.length > MAX_PROMPT) throw new Error('Prompt too long — likely to time out');","typeGuard":"null","tryCatchPattern":"try { await veo3.process(prompt); } catch (e) { if ((e as Error).message === 'Video generation timed out') return retryWithBackoff(() => veo3.process(prompt), 2); throw e; }","preventionTips":["Run generations as resumable background jobs, not blocking calls","Keep prompts/resolution modest","Track provider latency and alert before the 30-min budget is hit"],"tags":["veo3","timeout","polling","video-generation"],"backgroundTag":"long-running-job-timeout","analyzedSha":"0f1647f7491a217d43eb5ae7a480484bdf0aff3e","analyzedAt":"2026-08-27T12:09:55.020Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}