{"record":{"id":"7e3f87d5b2ca8456","repo":"jackwener/OpenCLI","slug":"gemini-image-timeoutseconds-gemini-was-still","errorCode":null,"errorMessage":"'gemini image', timeoutSeconds, 'Gemini was still generating at the deadline. Re-run with a higher --timeout.'","messagePattern":"'gemini image', timeoutSeconds, 'Gemini was still generating at the deadline\\. Re-run with a higher --timeout\\.'","errorType":"exception","errorClass":"TimeoutError","httpStatus":null,"severity":"error","filePath":"clis/gemini/utils.js","lineNumber":2425,"sourceCode":"        }\n        if (stillGenerating)\n            continue;\n        const urls = (await getGeminiVisibleImageUrls(page)).filter((url) => !beforeSet.has(url));\n        if (urls.length === 0)\n            continue;\n        const key = urls.join('\\n');\n        const prevKey = lastUrls.join('\\n');\n        if (key == prevKey)\n            stableCount += 1;\n        else {\n            lastUrls = urls;\n            stableCount = 1;\n        }\n        if (stableCount >= 2 || index === maxPolls - 1)\n            return lastUrls;\n    }\n    if (stillGenerating) {\n        throw new TimeoutError('gemini image', timeoutSeconds, 'Gemini was still generating at the deadline. Re-run with a higher --timeout.');\n    }\n    return lastUrls;\n}\nexport async function exportGeminiImages(page, urls) {\n    await ensureGeminiPage(page);\n    const urlsJson = JSON.stringify(urls);\n    const result = await page.evaluate(`\n    (async (targetUrls) => {\n      const blobToDataUrl = (blob) => new Promise((resolve, reject) => {\n        const reader = new FileReader();\n        reader.onloadend = () => resolve(String(reader.result || ''));\n        reader.onerror = () => reject(new Error('Failed to read blob'));\n        reader.readAsDataURL(blob);\n      });\n\n      const inferMime = (value, fallbackUrl) => {\n        if (value) return value;\n        const lower = String(fallbackUrl || '').toLowerCase();","sourceCodeStart":2407,"sourceCodeEnd":2443,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/gemini/utils.js#L2407-L2443","documentation":"TimeoutError thrown by the Gemini image polling helper after the poll loop exhausted its attempts (maxPolls) while the UI still reported 'still generating'. The library polls the Gemini response DOM for stable image URLs and gives up at the user-supplied deadline rather than returning partial results.","triggerScenarios":"Calling the gemini image command (exportGeminiImages/waitForGeminiResponse flow at clis/gemini/utils.js:2425) when Gemini has not finished generating all images within timeoutSeconds; slow model, long prompt, or too-low --timeout value.","commonSituations":"Default timeout too short for image generation; browser/session slowness; Gemini under heavy load producing images slowly; generating multiple high-resolution images.","solutions":["Re-run with a higher --timeout value (e.g. --timeout 300)","Simplify the prompt or request fewer images per run","Check network/browser performance and retry when Gemini responds faster"],"exampleFix":"// before\nopencli gemini image \"a watercolor castle\"\n// after\nopencli gemini image \"a watercolor castle\" --timeout 300","handlingStrategy":"retry","validationCode":"const timeoutSeconds = Number(opts.timeout ?? 120);\nif (!Number.isFinite(timeoutSeconds) || timeoutSeconds < 60) {\n  throw new Error('gemini image needs a generous --timeout (>= 60s recommended, 300s for multiple images)');\n}","typeGuard":null,"tryCatchPattern":"import { TimeoutError } from 'opencli/errors';\ntry {\n  const urls = await waitForGeminiResponse(page, baseline, prompt, timeoutSeconds);\n} catch (err) {\n  if (err instanceof TimeoutError && err.kind === 'gemini image') {\n    return retryWith({ timeout: timeoutSeconds * 2 });\n  }\n  throw err;\n}","preventionTips":["Pass an explicit --timeout of 120-300s for image generation","Request fewer images per prompt to shorten generation time","Retry once with doubled timeout before reporting failure"],"tags":["timeout","browser-automation","gemini"],"backgroundTag":"generation-timeout","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}