Getting 9523 errors when processing large images with R2 + Images API binding
Hi! 👋
We're experiencing an issue with our image-processing worker that uses R2 bucket bindings together with the Images API binding.
Some large images are failing with error code
9523, and we'd appreciate some guidance on what might be causing this.
Problem
Some large images return error code 9523 when processed through our image-processing worker, even though:
- The file is valid (can be viewed directly)
- Most images work fine with the R2 + Images API combo
- The issue occurs both in production and locally with wrangler dev using remote bindings
Example: A valid PNG (~34MB) fails with 9523 when processed through the Images API binding.
1. Image-processing worker fetches the image from R2 (env.IMAGES_BUCKET.get(imageId))
2. We create a Response from the R2 object body: new Response(r2Object.body, {...})
3. When calling env.IMAGES.input(response.body) with the Response's ReadableStream body, it fails with error 9523
Questions:
1. Are there size limits or memory constraints we should be aware of for large images?
2. Do you have examples or best practices for using R2 + Images API bindings together, especially for large images?
Architecture Context
1. Receives GET request with imageId and query params (width, height, format, quality, etc.)
2. Fetches image from R2 using IMAGES_BUCKET.get(imageId)
3. Creates a Response from the R2 object body:
const r2Object = await env.IMAGES_BUCKET.get(imageId);
const response = new Response(r2Object.body);
4. Uses Images API binding (IMAGES) to transform by passing the Response body (ReadableStream) directly:
let transform = env.IMAGES.input(response.body);
transform = transform.transform({ width, height, fit, background });
const result = await transform.output({ format, quality });
return result.response();
5. Returns transformed image
Thanks in advance! 🙏0 Replies