Skip to content

WC-4866: Implement ctx.exports loopback in the Asset Worker#13354

Merged
petebacondarwin merged 23 commits intocloudflare:mainfrom
courtney-sims:wc-4866
Apr 14, 2026
Merged

WC-4866: Implement ctx.exports loopback in the Asset Worker#13354
petebacondarwin merged 23 commits intocloudflare:mainfrom
courtney-sims:wc-4866

Conversation

@courtney-sims
Copy link
Copy Markdown
Contributor

@courtney-sims courtney-sims commented Apr 8, 2026

Fixes https://jira.cfdata.org/browse/WC-4866

This PR introduces a loopback pattern to the Asset Worker. In production, every public method on the outer entrypoint (fetch, unstable_canFetch, unstable_getByETag, unstable_getByPathname, unstable_exists) is forwarded through ctx.exports.AssetWorkerEntrypoint to an inner entrypoint. This establishes the infrastructure needed for future cohort-based versioned deployments.

The Vite plugin subclasses AssetWorker and overrides unstable_exists and unstable_getByETag with dev-server-backed implementations. isSubclassedForLocalDev() detects this and skips loopback.


  • Tests
    • Tests included/updated
    • Automated tests not possible
    • Additional testing not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: No usability impact

A picture of a cute animal (not mandatory, but encouraged)
catcomputer


Open with Devin

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 8, 2026

🦋 Changeset detected

Latest commit: f77280b

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@workers-devprod workers-devprod requested review from a team and petebacondarwin and removed request for a team April 8, 2026 20:10
@workers-devprod
Copy link
Copy Markdown
Contributor

workers-devprod commented Apr 8, 2026

Codeowners approval required for this PR:

  • @cloudflare/wrangler
  • ✅ @cloudflare/deploy-config
Show detailed file reviewers
  • packages/miniflare/src/plugins/assets/index.ts: [@cloudflare/wrangler]
  • packages/miniflare/src/workers/assets/assets.worker.ts: [@cloudflare/wrangler]
  • packages/workers-shared/asset-worker/src/worker.ts: [@cloudflare/wrangler]
  • packages/workers-shared/asset-worker/worker-configuration.d.ts: [@cloudflare/wrangler]
  • packages/workers-shared/asset-worker/wrangler.jsonc: [@cloudflare/wrangler]

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 4 additional findings.

Open in Devin Review

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 8, 2026

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@13354

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@13354

miniflare

npm i https://pkg.pr.new/miniflare@13354

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@13354

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@13354

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@13354

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@13354

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@13354

wrangler

npm i https://pkg.pr.new/wrangler@13354

commit: f77280b

Comment thread .changeset/asset-worker-loopback.md
Comment thread packages/vite-plugin-cloudflare/src/workers/asset-worker/index.ts Outdated
Comment thread fixtures/workers-shared-asset-config/redirects.test.ts Outdated
Comment thread packages/miniflare/src/workers/assets/assets.worker.ts Outdated
Comment thread packages/workers-shared/asset-worker/worker-configuration.d.ts
Comment thread packages/workers-shared/asset-worker/worker-configuration.d.ts
Comment thread packages/workers-shared/asset-worker/src/worker.ts
Comment thread packages/workers-shared/asset-worker/src/worker.ts
Copy link
Copy Markdown
Contributor

@GregBrimble GregBrimble left a comment

Choose a reason for hiding this comment

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

LGTM :)

@workers-devprod
Copy link
Copy Markdown
Contributor

workers-devprod commented Apr 13, 2026

Codeowners approval required for this PR:

  • ✅ @cloudflare/deploy-config
  • ✅ @cloudflare/wrangler
Show detailed file reviewers

courtney-sims and others added 3 commits April 13, 2026 17:02
…edForLocalDev from outer

The outer entrypoint (AssetWorkerOuter) no longer needs dev-specific
branches. Instead, the Vite plugin's CustomAssetWorker extends
AssetWorkerInner directly, skipping the production loopback layer
entirely for local development. This keeps AssetWorkerOuter as a
clean dispatch-only layer for ctx.exports forwarding.
Copy link
Copy Markdown
Contributor

@petebacondarwin petebacondarwin left a comment

Choose a reason for hiding this comment

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

I added a commit that removes the need to check for local dev overrides in the production worker code, and instead just changes how the vite plugin creates its own version of the asset worker.

Copy link
Copy Markdown
Contributor

@workers-devprod workers-devprod left a comment

Choose a reason for hiding this comment

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

Codeowners reviews satisfied

@github-project-automation github-project-automation bot moved this from Untriaged to Approved in workers-sdk Apr 14, 2026
@petebacondarwin petebacondarwin merged commit 854d66c into cloudflare:main Apr 14, 2026
56 of 58 checks passed
@github-project-automation github-project-automation bot moved this from Approved to Done in workers-sdk Apr 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants