{"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":309,"sourceCode":"\t\t\t\t});\n\t\t\t\treturn { response: reconstructed, metadata: envelope.metadata };\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":291,"sourceCodeEnd":327,"githubUrl":"https://github.com/withastro/astro/blob/d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca/packages/integrations/cloudflare/src/prerenderer.ts#L291-L327","documentation":"Thrown by the Cloudflare prerenderer when collecting build-time-optimized static images: the POST to the `STATIC_IMAGES_ENDPOINT` on the local workerd server returns non-OK. Only active when a build-time image service is configured (`compile`, `custom`, or `cloudflare-binding` build service). The response body is appended as `details`.","triggerScenarios":"During build with build-time image optimization enabled, `collectStaticImages` POSTs to the workerd server and the response is not OK. Causes: workerd image handler crash, missing Cloudflare Images binding, or an invalid transform encountered during static image collection.","commonSituations":"Configuring `imageService` as `cloudflare-binding` for build-time transforms without a real Images binding locally. A malformed `<Image>` component config (invalid width/height/format). workerd image service version mismatch.","solutions":["Read the `details` body for the workerd image-service error.","Verify the Cloudflare Images binding is configured (`images: { binding: 'MY_IMAGES' }`) and available locally.","If you do not need build-time transforms, switch `imageService` to a runtime-only or Node-compatible service (e.g. sharp) to bypass this code path.","Audit `<Image>` usages for invalid transform parameters."],"exampleFix":"// before — build-time images without binding\nexport default defineConfig({\n  adapter: cloudflare({ imageService: 'cloudflare-binding' }),\n});\n\n// after — provide the binding or use passthrough\nexport default defineConfig({\n  adapter: cloudflare({ imageService: 'passthrough' }),\n});","handlingStrategy":"validation","validationCode":"// Before enabling build-time images, confirm the Images binding:\n// wrangler.jsonc must declare images.binding matching the adapter config.\nconst wrangler = require('./wrangler.jsonc');\nif (!wrangler.images?.binding) {\n  throw new Error('Configure images.binding before using cloudflare-binding imageService');\n}","typeGuard":null,"tryCatchPattern":"try {\n  await build();\n} catch (e) {\n  if (/Failed to get static images/.test(e.message)) {\n    // details body has workerd image error; fall back to passthrough/sharp imageService\n  }\n  throw e;\n}","preventionTips":["Only enable cloudflare-binding imageService if you have a real Images binding.","Validate all <Image> component props (positive width/height, supported format).","Fall back to a Node-compatible imageService for builds that do not need Cloudflare Images."],"tags":["cloudflare","prerender","images","build","workerd"],"backgroundTag":null,"analyzedSha":"d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca","analyzedAt":"2026-08-12T13:37:29.035Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}