{"record":{"id":"77ed56131ad5e1f7","repo":"withastro/astro","slug":"failed-to-get-static-images-from-the-cloudflare-pr","errorCode":null,"errorMessage":"Failed to get static images from the Cloudflare prerender server (${response.status}: ${response.statusText}).${details}","messagePattern":"Failed to get static images from the Cloudflare prerender server \\((.+?): (.+?)\\)\\.(.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/integrations/cloudflare/src/prerenderer.ts","lineNumber":296,"sourceCode":"\t\t\tif (collectMetadata) {\n\t\t\t\treturn readFramedPrerenderResponse(response);\n\t\t\t}\n\n\t\t\treturn response;\n\t\t},\n\n\t\tcollectStaticImages:\n\t\t\thasBuildImageService || hasBindingImageService\n\t\t\t\t? async (): Promise<AssetsGlobalStaticImagesList> => {\n\t\t\t\t\t\tconst response = await fetch(`${serverUrl}${STATIC_IMAGES_ENDPOINT}`, {\n\t\t\t\t\t\t\tmethod: 'POST',\n\t\t\t\t\t\t\theaders: { 'Content-Type': 'application/json' },\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tif (!response.ok) {\n\t\t\t\t\t\t\tconst body = await response.text();\n\t\t\t\t\t\t\tconst details = body ? `\\n${body}` : '';\n\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t`Failed to get static images from the Cloudflare prerender server (${response.status}: ${response.statusText}).${details}`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst entries: StaticImagesResponse = await response.json();\n\n\t\t\t\t\t\t// Transforms left in this map fall through to the Node-side image\n\t\t\t\t\t\t// service (the user-configured service, or Sharp).\n\t\t\t\t\t\tconst staticImages: AssetsGlobalStaticImagesList = new Map();\n\t\t\t\t\t\tconst deferToNodeImageService = (\n\t\t\t\t\t\t\tentry: SerializedStaticImageEntry,\n\t\t\t\t\t\t\tt: SerializedStaticImageEntry['transforms'][number],\n\t\t\t\t\t\t) => {\n\t\t\t\t\t\t\tlet existing = staticImages.get(entry.originalPath);\n\t\t\t\t\t\t\tif (!existing) {\n\t\t\t\t\t\t\t\texisting = { originalSrcPath: entry.originalSrcPath, transforms: new Map() };\n\t\t\t\t\t\t\t\tstaticImages.set(entry.originalPath, existing);\n\t\t\t\t\t\t\t}","sourceCodeStart":278,"sourceCodeEnd":314,"githubUrl":"https://github.com/withastro/astro/blob/e294953aa8aadd98d5be92e60a03037b05dbdfd4/packages/integrations/cloudflare/src/prerenderer.ts#L278-L314","documentation":"When the Cloudflare adapter is configured with a build-time image service (compile/custom) or an Images binding, the build asks the workerd prerender server for the list of image transforms to materialize as static assets. A non-OK response from that internal endpoint fails the build with this error, including the workerd body for diagnosis. It indicates the worker-side image collection failed, not that a specific image was invalid.","triggerScenarios":"`astro build` with `imageService: 'compile'`/`'custom'` or a Cloudflare Images binding configured, and the workerd process fails while collecting optimized image transforms (e.g. an image service module erroring under workerd, adapter/runtime mismatch).","commonSituations":"Switching the adapter's imageService configuration; upgrading astro/adapter/workerd to incompatible versions; a custom image service whose code paths break in workerd.","solutions":["Inspect the body appended to the message for the workerd stack trace.","Temporarily switch imageService back to the default (or 'passthrough') to confirm the image pipeline is the culprit.","Update @astrojs/cloudflare, astro, and wrangler/workerd together so image collection code matches.","If using a custom image service, test it under workerd (`wrangler dev`) before build."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await build({ root: './' });\n} catch (e) {\n  const msg = e instanceof Error ? e.message : String(e);\n  if (msg.includes('Failed to get static images')) {\n    console.error('Image collection failed inside workerd:', msg);\n    process.exitCode = 1;\n  } else throw e;\n}","preventionTips":["Smoke-test custom image services under workerd before wiring them into build.","Update adapter, astro, and workerd as a set when using compile-time image optimization.","Keep a CI build so image-pipeline regressions are caught pre-deploy."],"tags":["cloudflare","images","prerender","build","image-service"],"backgroundTag":"prerender-request-failed","analyzedSha":"e294953aa8aadd98d5be92e60a03037b05dbdfd4","analyzedAt":"2026-08-18T18:48:03.901Z","contentChangedAt":"2026-08-18T18:48:03.901Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}