gitroomhq/postiz-app · error · Error
Video generation timed out
Error message
Video generation timed out
What it means
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'.
Source
Thrown at libraries/nestjs-libraries/src/videos/veo3/veo3.ts:71
prompt: customParams.prompt,
imageUrls: customParams?.images?.map((p) => p.path) || [],
model: 'veo3_fast',
aspectRatio: output === 'horizontal' ? '16:9' : '9:16',
}),
})
).json();
if (value.code !== 200 && value.code !== 201) {
throw new Error(value?.msg || `Failed to generate video`);
}
const taskId = value.data.taskId;
console.log('veo3 taskId', taskId);
let attempts = 0;
const maxAttempts = 180; // ~30 minutes at 10s interval
while (true) {
if (attempts++ >= maxAttempts) {
throw new Error('Video generation timed out');
}
console.log('waiting for video to be ready');
const data = await (
await fetch(
'https://api.kie.ai/api/v1/veo/record-info?taskId=' + taskId,
{
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${process.env.KIEAI_API_KEY}`,
},
signal: AbortSignal.timeout(30000),
}
)
).json();
if (data.code !== 200) {
throw new Error(data?.msg || `Failed to get video info`);View on GitHub (pinned to 0f1647f749)
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
Example fix
// before
const maxAttempts = 180; // ~30 minutes
// after (run inside a Temporal activity with retry policy)
const maxAttempts = 360; // ~60 min, plus activity retry from workflow
// and configure: retry: { maximumAttempts: 3 } on the activity options Defensive patterns
Strategy: retry
Validate before calling
if (!prompt || prompt.length > MAX_PROMPT) throw new Error('Prompt too long — likely to time out'); Type guard
null
Try / catch
try { await veo3.process(prompt); } catch (e) { if ((e as Error).message === 'Video generation timed out') return retryWithBackoff(() => veo3.process(prompt), 2); throw e; } Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
- Timeouts: ETIMEDOUT, deadlines, and hung requests — what actually expires when a request times out.
Related errors
- Threads took too long to process the media, please try again
- TikTok refused to publish your post
- Failed to generate video
- Failed to get video info
- Video generation failed (status ${successFlag})
AI-assisted analysis of gitroomhq/postiz-app@0f1647f749 (2026-08-27).
Data as JSON: /api/errors/66f87aac3288a8da.
Report an issue: GitHub.