withastro/astro · error · Error

Failed to get static images from the Cloudflare prerender…

Error message

Failed to get static images from the Cloudflare prerender server (${response.status}: ${response.statusText}).${details}

What it means

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.

Solutions

  1. Inspect the body appended to the message for the workerd stack trace.
  2. Temporarily switch imageService back to the default (or 'passthrough') to confirm the image pipeline is the culprit.
  3. Update @astrojs/cloudflare, astro, and wrangler/workerd together so image collection code matches.
  4. If using a custom image service, test it under workerd (`wrangler dev`) before build.
Defensive patterns

Strategy: try-catch

Try / catch

try {
  await build({ root: './' });
} catch (e) {
  const msg = e instanceof Error ? e.message : String(e);
  if (msg.includes('Failed to get static images')) {
    console.error('Image collection failed inside workerd:', msg);
    process.exitCode = 1;
  } else throw e;
}

Prevention

When it happens

Trigger: `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).

Common situations: Switching the adapter's imageService configuration; upgrading astro/adapter/workerd to incompatible versions; a custom image service whose code paths break in workerd.

Related errors


AI-assisted analysis of withastro/astro@e294953aa8 (2026-08-18). Data as JSON: /api/errors/77ed56131ad5e1f7. Report an issue: GitHub.

Appendix: source

Thrown at packages/integrations/cloudflare/src/prerenderer.ts:296

			if (collectMetadata) {
				return readFramedPrerenderResponse(response);
			}

			return response;
		},

		collectStaticImages:
			hasBuildImageService || hasBindingImageService
				? async (): Promise<AssetsGlobalStaticImagesList> => {
						const response = await fetch(`${serverUrl}${STATIC_IMAGES_ENDPOINT}`, {
							method: 'POST',
							headers: { 'Content-Type': 'application/json' },
						});

						if (!response.ok) {
							const body = await response.text();
							const details = body ? `\n${body}` : '';
							throw new Error(
								`Failed to get static images from the Cloudflare prerender server (${response.status}: ${response.statusText}).${details}`,
							);
						}

						const entries: StaticImagesResponse = await response.json();

						// Transforms left in this map fall through to the Node-side image
						// service (the user-configured service, or Sharp).
						const staticImages: AssetsGlobalStaticImagesList = new Map();
						const deferToNodeImageService = (
							entry: SerializedStaticImageEntry,
							t: SerializedStaticImageEntry['transforms'][number],
						) => {
							let existing = staticImages.get(entry.originalPath);
							if (!existing) {
								existing = { originalSrcPath: entry.originalSrcPath, transforms: new Map() };
								staticImages.set(entry.originalPath, existing);
							}

View on GitHub (pinned to e294953aa8)