{"record":{"id":"859e15c43ddf020d","repo":"vercel/ai","slug":"video-generation-timed-out-after-timeoutms-ms","errorCode":null,"errorMessage":"Video generation timed out after ${timeoutMs}ms.","messagePattern":"Video generation timed out after (.+?)ms\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/ai/src/generate-video/generate-video.ts","lineNumber":555,"sourceCode":"  const delay = pollConfig?.delay ?? defaultDelay;\n  const startTime = Date.now();\n\n  if (webhookReceived != null) {\n    // 3a. Webhook flow: wait for webhook, then get final status\n    await waitForWebhook({\n      received: webhookReceived,\n      timeoutMs,\n      abortSignal: callOptions.abortSignal,\n      delay,\n    });\n  }\n\n  while (true) {\n    if (webhookReceived == null) {\n      // 3b. Polling flow (also used when webhooks are not supported)\n      const elapsedMs = Date.now() - startTime;\n      if (elapsedMs >= timeoutMs) {\n        throw new Error(`Video generation timed out after ${timeoutMs}ms.`);\n      }\n      await delay(Math.min(intervalMs, timeoutMs - elapsedMs), {\n        abortSignal: callOptions.abortSignal,\n      });\n      if (Date.now() - startTime >= timeoutMs) {\n        throw new Error(`Video generation timed out after ${timeoutMs}ms.`);\n      }\n    }\n\n    const statusResult = await retry(() =>\n      model.doStatus!({\n        operation: startResult.operation,\n        abortSignal: callOptions.abortSignal,\n        headers: callOptions.headers,\n      }),\n    );\n\n    if (statusResult.status === 'error') {","sourceCodeStart":537,"sourceCodeEnd":573,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/ai/src/generate-video/generate-video.ts#L537-L573","documentation":"In the start/status (polling) flow of experimental_generateVideo, the SDK polls model.doStatus until the operation completes; if the elapsed time since the operation started reaches timeoutMs before completion, it throws 'Video generation timed out after {timeoutMs}ms'. Video generation is slow and asynchronous, so the SDK bounds polling with the caller-provided (or default) timeout.","triggerScenarios":"The provider operation stays pending longer than timeoutMs — very long generations, a stuck/failed provider operation that never changes status, or an explicitly low timeoutMs passed via poll/timeout options.","commonSituations":"Setting timeoutMs too small for a slow video model; provider incidents where status never leaves 'pending'; queuing delays at the provider during peak load; passing timeoutMs in the wrong unit (seconds vs milliseconds).","solutions":["Increase the timeout option passed to experimental_generateVideo to cover realistic generation times (minutes, not seconds).","Check the provider dashboard/logs to see if the operation actually failed or is queued.","Retry the generation; a fresh operation may complete faster.","Verify the timeout unit is milliseconds.","Wrap the call in try/catch and re-submit with a larger timeout on timeout errors."],"exampleFix":"// before\nawait experimental_generateVideo({ model, prompt, poll: { timeoutMs: 10_000 } });\n\n// after\nawait experimental_generateVideo({ model, prompt, poll: { timeoutMs: 600_000 } }); // allow 10 minutes","handlingStrategy":"retry","validationCode":"const MIN_VIDEO_TIMEOUT_MS = 5 * 60_000;\nif (poll?.timeoutMs != null && poll.timeoutMs < MIN_VIDEO_TIMEOUT_MS) {\n  console.warn(`timeoutMs ${poll.timeoutMs} is likely too small for video generation`);\n}","typeGuard":"null","tryCatchPattern":"try {\n  const result = await experimental_generateVideo({ model, prompt, poll: { timeoutMs: 600_000, intervalMs: 10_000 } });\n} catch (error) {\n  if (error instanceof Error && /Video generation timed out/.test(error.message)) {\n    // check provider operation status, then resubmit with a larger timeout\n  } else throw error;\n}","preventionTips":["Set timeouts in minutes for video generation, not seconds.","Keep intervalMs well below timeoutMs so several status checks fit.","Check the provider operation via the start result after a timeout before retrying.","Watch provider status pages for incidents that stall operations."],"tags":["video","timeout","polling","network"],"backgroundTag":"operation-timeout","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}