{"record":{"id":"ec381f5535770fc1","repo":"vercel/ai","slug":"image-generation-timed-out-after-this-maxpollatt","errorCode":null,"errorMessage":"Image generation timed out after ${this.maxPollAttempts} attempts.","messagePattern":"Image generation timed out after (.+?) attempts\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/luma/src/luma-image-model.ts","lineNumber":212,"sourceCode":"      switch (statusResponse.state) {\n        case 'completed':\n          if (!statusResponse.assets?.image) {\n            throw new InvalidResponseDataError({\n              data: statusResponse,\n              message: `Image generation completed but no image was found.`,\n            });\n          }\n          return statusResponse.assets.image;\n        case 'failed':\n          throw new InvalidResponseDataError({\n            data: statusResponse,\n            message: `Image generation failed.`,\n          });\n      }\n      await delay(pollIntervalMillis);\n    }\n\n    throw new Error(\n      `Image generation timed out after ${this.maxPollAttempts} attempts.`,\n    );\n  }\n\n  private createLumaErrorHandler() {\n    return createJsonErrorResponseHandler({\n      errorSchema: lumaErrorSchema,\n      errorToMessage: (error: LumaErrorData) =>\n        error.detail[0].msg ?? 'Unknown error',\n    });\n  }\n\n  private getEditingOptions(\n    files: ImageModelV4File[] | undefined,\n    mask: ImageModelV4File | undefined,\n    referenceType: LumaReferenceType = 'image',\n    imageConfigs: Array<{ weight?: number | null; id?: string | null }> = [],\n  ): Record<string, unknown> {","sourceCodeStart":194,"sourceCodeEnd":230,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/luma/src/luma-image-model.ts#L194-L230","documentation":"Thrown by pollForImageUrl when the Luma image generation request did not reach a terminal state within maxPollAttempts polling cycles. Luma's generate API is asynchronous: the model polls the generation status until it succeeds or fails, and this generic Error signals the polling budget was exhausted. It does not indicate the image definitively failed — generation may still complete later on Luma's side.","triggerScenarios":"Calling generateImage/doGenerate with a luma.imageModel(...) while the generation stays in a non-terminal state (e.g. 'queued'/'dreaming') for longer than maxPollAttempts × pollIntervalMillis. Typical with slow models, heavy queue times, or when maxPollAttempts/pollIntervalMillis provider options are set too low.","commonSituations":"Long Luma API queue during peak hours; developers passing a small maxPollAttempts (e.g. 10) with a short pollIntervalMillis; complex multi-reference requests that take longer to render; network latency making each poll slower than intended.","solutions":["Increase the maxPollAttempts provider option (e.g. to 30-60) when constructing the image model.","Increase pollIntervalMillis so Luma has more wall-clock time between status checks.","Retry the generation once; transient queue delays often resolve on a second attempt.","If it persists, check Luma's status/queue conditions or reduce prompt complexity (fewer reference images, simpler aspect ratio)."],"exampleFix":"// before\nconst luma = createLuma({ apiKey });\nconst model = luma.image('photon-flash-1');\n// after\nconst luma = createLuma({ apiKey });\nconst model = luma.image('photon-flash-1', {\n  maxPollAttempts: 60,\n  pollIntervalMillis: 2000,\n});","handlingStrategy":"retry","validationCode":"// Ensure generous polling budget before calling\nconst opts = { maxPollAttempts: 60, pollIntervalMillis: 2000 };\nif ((opts.maxPollAttempts * opts.pollIntervalMillis) < 60000) {\n  throw new Error('Polling budget under 60s; increase maxPollAttempts/pollIntervalMillis');\n}","typeGuard":null,"tryCatchPattern":"try {\n  const { image } = await generateImage({ model: luma.image('photon-flash-1', { maxPollAttempts: 60 }), prompt });\n} catch (e) {\n  if (e instanceof Error && /timed out after \\d+ attempts/.test(e.message)) {\n    // retry once with a larger budget\n    return generateImage({ model: luma.image('photon-flash-1', { maxPollAttempts: 120 }), prompt });\n  }\n  throw e;\n}","preventionTips":["Always set maxPollAttempts and pollIntervalMillis explicitly for production workloads.","Budget at least 1-2 minutes of total polling time for Luma generations.","Wrap generation in a retry with exponential backoff for queue-related timeouts.","Alert on repeated timeout rates to detect Luma queue degradation."],"tags":["timeout","image-generation","polling","luma"],"backgroundTag":"poll-timeout-exceeded","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}