withastro/astro · warning
Could not optimize "${entry.originalPath}" with the Cloudfla
Error message
Could not optimize "${entry.originalPath}" with the Cloudflare IMAGES binding (${message}). Falling back to the local image service. What it means
When the Cloudflare adapter prerenders, optimized image variants are produced through the IMAGES binding inside a local workerd server. If a request to that server fails (binding unavailable or misconfigured, unsupported source format or transform, missing source), the adapter logs this warning and defers the transform to the Node-side image service (your configured service, or Sharp) so the build still emits images. The build succeeds — output is simply generated locally instead of by the Cloudflare IMAGES binding.
Source
Thrown at packages/integrations/cloudflare/src/prerenderer.ts:351
);
return entry.transforms.map((t) => ({ entry, t, sourcePath }));
});
await forEachWithConcurrency(
jobs,
IMAGE_TRANSFORM_CONCURRENCY,
async ({ entry, t, sourcePath }) => {
try {
await writeTransformedImage(
serverUrl,
clientDir,
entry.originalPath,
t.finalPath,
t.transform,
sourcePath,
);
} catch (err) {
const message = err instanceof Error ? err.message : String(err);
logger.warn(
`Could not optimize "${entry.originalPath}" with the Cloudflare IMAGES binding (${message}). Falling back to the local image service.`,
);
deferToNodeImageService(entry, t);
}
},
);
} else {
for (const entry of entries) {
for (const t of entry.transforms) {
deferToNodeImageService(entry, t);
}
}
}
// Only load the Node-side image service if some transforms still need it.
if (staticImages.size > 0) {
globalThis.astroAsset ??= {};
if (userImageServiceEntrypoint) {View on GitHub (pinned to e294953aa8)
Solutions
- Read the parenthetical message — it is the raw workerd error telling you exactly what failed
- Verify the IMAGES binding configuration in your wrangler config matches the adapter docs (binding name, compatibility settings)
- Ensure local source images exist in the project and remote image domains are explicitly allowed
- Keep sharp installed so the fallback produces correct output, or accept the fallback if the binding cannot run at build time
Defensive patterns
Strategy: fallback
Validate before calling
// Ensure the fallback image service is actually installable in CI
// package.json devDependencies must include sharp when you rely on the local fallback:
// "sharp": "^0.33" — verify with:
import sharp from 'sharp';
console.log('fallback image service ok:', typeof sharp === 'function'); Prevention
- Keep wrangler images-binding config in sync with the adapter version's docs
- Declare remote image domains explicitly so the binding can fetch them
- Test `astro build` in the same environment you deploy from — workerd binding behavior differs across OSes
- Treat the warning as build-time only: the emitted images come from Sharp, so verify their quality/size after builds
When it happens
Trigger: `astro build` with the Cloudflare adapter in binding-image-service mode; the per-transform request to the prerender server throws (workerd error surfaces in parentheses); source images in formats the binding cannot process or remote images whose domains are not allowed.
Common situations: wrangler.toml/jsonc missing or mismatching the images binding configuration the adapter expects; upgrading adapter/wrangler versions; CI where workerd cannot run the binding; remote images not covered by image domains config.
Related errors
- Failed to get static images from the Cloudflare prerender se
- The Sharp image service cannot run inside the workerd runtim
- The current configuration does not support image optimizatio
- the prerender server responded ${response.status} ${response
- Failed to start the Cloudflare prerender server. The preview
AI-assisted analysis of withastro/astro@e294953aa8 (2026-08-18).
Data as JSON: /api/errors/d7fbadac0b4b4e0d.
Report an issue: GitHub.