[wrangler] Move binding local-development support into a single registry - #13728
Conversation
Adds a `getBindingLocalSupport()` helper in workers-utils as the source of truth for whether each binding type has a local simulator, optional remote proxy, or no local sim at all. `pickRemoteBindings()` and `warnOrError()` now both consult this helper instead of duplicating hard-coded type lists. Adding a new always-remote binding is now a single, auditable edit guarded by a deliberately verbose `DO-NOT-USE-this-resource-will-never-have-a-local-simulator` discriminator. Also fixes a latent bug: `remote: false` on always-remote bindings (AI, AI Search, Media, Artifacts, Flagship, VPC) was previously silently accepted and produced a non-functional binding. `wrangler dev` now fails with a clear error directing users to either remove the `remote` field or set it to `true`.
🦋 Changeset detectedLatest commit: 8d5be82 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
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 |
|
Codeowners approval required for this PR:
Show detailed file reviewers
|
|
✅ All changesets look good |
|
I'm Bonk, and I've done a quick review of your PR. This PR consolidates per-binding-type local-dev support classification into a single registry in Issues found:
|
create-cloudflare
@cloudflare/deploy-helpers
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-shared
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-pool-workers
@cloudflare/workers-editor-shared
@cloudflare/workers-utils
wrangler
commit: |
ascorbic
left a comment
There was a problem hiding this comment.
Sorry for the delay in getting to this! It looks good (subject to the merge conflict), though it doesn't look there is a test that exercises the remote: false+ remote only path, so it might be good to add one to check the thrown error.
…s-remote # Conflicts: # packages/wrangler/src/utils/print-bindings.ts
|
Codeowners approval required for this PR:
Show detailed file reviewers |
workers-devprod
left a comment
There was a problem hiding this comment.
Codeowners reviews satisfied
Consolidates the per-binding-type local-dev support classification into a single source-of-truth registry, and makes adding a new always-remote binding deliberately friction-y.
The "is this binding type always-remote / has a local simulator / accepts
remote: true" knowledge was previously fragmented across three places that had to be kept in sync by hand:ifchain insidepickRemoteBindings()(packages/wrangler/src/api/remoteBindings/index.ts).supportsliteral threaded through everywarnOrError(...)call site inpackages/wrangler/src/dev/miniflare/index.ts.workers-utils.This PR introduces
getBindingLocalSupport()in@cloudflare/workers-utilsas the single registry.pickRemoteBindings()andwarnOrError()both consult it. Adding a new always-remote binding is now a one-line edit in one obvious file, and the type-level variant for "no local simulator, ever" is the deliberately verboseDO-NOT-USE-this-resource-will-never-have-a-local-simulatorso that adding to it shows up in PR diffs as an obvious red flag for reviewers. The neighbouringremotevariant carries a temporal "no local simulator yet" connotation — bindings there should move tolocal-and-remoteonce a local sim lands.The exhaustive
Record<Binding["type"], BindingLocalSupport>constraint catches drift at compile time: adding a new variant toBinding["type"]forces an accompanying registry entry.Also fixes a latent bug noticed during the refactor:
remote: falseon always-remote bindings (AI, AI Search, Media, Artifacts, Flagship, VPC Service, VPC Network) was previously silently accepted and produced a non-functional binding.wrangler devnow fails with a clear error directing users to either remove theremotefield or set it totrue. By symmetry withremote: trueon bindings that lack remote support, an explicit contradiction in the config is now reported instead of silently no-oped.While auditing classifications, also surfaced #13727 — Miniflare's queues plugin silently ignores
remote: trueon queue producers (separate bug, separate fix).e2e/remote-binding/dev-remote-bindings.test.ts:182is byte-identical; and theremote: falsethrow is the symmetric counterpart of an existing throw with identical telemetry plumbing.remote: false-on-always-remote error message is self-explanatory and changeset-documented.