Skip to content

IMAGES-2139: switch images binding to a chainable handle#6288

Merged
ascorbic merged 1 commit intocloudflare:mainfrom
mglewis:mattl/IMAGES-2139-images-binding-chainable-handle
Apr 1, 2026
Merged

IMAGES-2139: switch images binding to a chainable handle#6288
ascorbic merged 1 commit intocloudflare:mainfrom
mglewis:mattl/IMAGES-2139-images-binding-chainable-handle

Conversation

@mglewis
Copy link
Copy Markdown
Member

@mglewis mglewis commented Mar 10, 2026

This PR updates the Images Binding interface to adopt a chainable handle pattern for per-image operations, bringing it more in line with the upcoming Stream Binding.

CRUD support was originally added in #5912 but has yet to be made generally available - at present it is gated to my developer account. This is technically a breaking change to the interface, but is safe as no external users will be impacted.

Changes

Previously, per-image operations were flat methods on the hosted namespace:

await env.IMAGES.hosted.details(id);
await env.IMAGES.hosted.update(id, { requireSignedURLs: true });
await env.IMAGES.hosted.delete(id);
const stream = await env.IMAGES.hosted.image(id); // raw bytes

These operations now go via an intermediate handle, returned synchronously from hosted.image(id):

const handle = env.IMAGES.hosted.image(id);
await handle.details();
await handle.update({ requireSignedURLs: true });
await handle.delete();
const stream = await handle.bytes(); // renamed from image()

Note that upload() and list() are unchanged.

Reviewer considerations

  • The breaking change to image() — which previously returned a Promise and now returns a synchronous handle — is the most significant thing to be aware of. Given the gating situation this should be fine, but worth a look.
  • The rename from image() to bytes() on the handle is deliberate, to avoid confusion now that image() is the handle factory.
  • The corresponding upstream service change is here

Testing

Unit tests. Will verify E2E against gated developer account before releasing more widely

@mglewis mglewis force-pushed the mattl/IMAGES-2139-images-binding-chainable-handle branch 2 times, most recently from cc7218a to eecb4cf Compare March 30, 2026 11:53
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Mar 30, 2026

Merging this PR will not alter performance

✅ 70 untouched benchmarks
⏩ 129 skipped benchmarks1


Comparing mglewis:mattl/IMAGES-2139-images-binding-chainable-handle (8692340) with main (5ecc6bf)

Open in CodSpeed

Footnotes

  1. 129 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@mglewis mglewis force-pushed the mattl/IMAGES-2139-images-binding-chainable-handle branch from eecb4cf to 888ea1c Compare March 30, 2026 12:21
@mglewis mglewis force-pushed the mattl/IMAGES-2139-images-binding-chainable-handle branch from 888ea1c to 8692340 Compare March 30, 2026 14:45
mglewis added a commit to mglewis/workers-sdk that referenced this pull request Mar 30, 2026
Tests are skipped pending the workerd API change in
cloudflare/workerd#6288
@mglewis mglewis force-pushed the mattl/IMAGES-2139-images-binding-chainable-handle branch from 2cfb8ac to 8692340 Compare March 31, 2026 15:33
@mglewis mglewis marked this pull request as ready for review April 1, 2026 11:46
@mglewis mglewis requested review from a team as code owners April 1, 2026 11:46
@mglewis mglewis requested a review from petebacondarwin April 1, 2026 11:46
Copy link
Copy Markdown
Contributor

@ascorbic ascorbic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving types

@ascorbic ascorbic merged commit 9bdd85c into cloudflare:main Apr 1, 2026
38 of 40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants