fix(wrangler): default dev.registry in unstable_startWorker like the CLI#14615
fix(wrangler): default dev.registry in unstable_startWorker like the CLI#14615martijnwalraven wants to merge 2 commits into
dev.registry in unstable_startWorker like the CLI#14615Conversation
The CLI resolves the dev registry to WRANGLER_REGISTRY_PATH or <global-config>/registry and passes it unconditionally unless --disable-dev-registry, but the programmatic path used input.dev.registry raw — undefined silently disabled cross-session service discovery, so startWorker workers could not resolve (or be resolved by) other local dev sessions' script_name bindings. Mirror `persist`: apply the CLI's default in resolveConfig, and widen the input type to `string | false` so callers can still opt out explicitly (the resolved config narrows back to `string | undefined`). The CLI's --disable-dev-registry and the API test harness now pass `false` — with undefined meaning "default", they must state the opt-out. The initial bindings print stays keyed on the explicit input (cosmetic; the CLI always passes a path, so its output is unchanged). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: e9f6380 The changes in this PR will be included in the next version bump. This PR includes changesets to release 8 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
|
| const devRegistryPath = | ||
| input.dev?.registry === false | ||
| ? undefined | ||
| : (input.dev?.registry ?? getRegistryPath()); |
There was a problem hiding this comment.
🔍 Semantic change: undefined for dev.registry now means 'use default' instead of 'disabled'
Before this PR, passing registry: undefined (or omitting it) in unstable_startWorker() meant the dev registry was disabled — programmatic workers were invisible to other dev sessions. After this PR, undefined means 'apply the CLI default' (getRegistryPath() at packages/wrangler/src/api/startDevWorker/ConfigController.ts:120), and callers must now pass false to disable. This is a deliberate behavioral change (the PR's stated purpose), but it is a breaking change for existing programmatic API consumers who relied on the previous default-off behavior. Any caller that previously omitted registry will now join the shared dev registry. The CLI path (packages/wrangler/src/dev/start-dev.ts:266) and test harness (packages/wrangler/src/api/test-harness.ts:449) are both updated, but external consumers of unstable_startWorker() (e.g. @cloudflare/vite-plugin or third-party tools) may need updating if they want the old behavior.
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
The semantic shift is the PR's stated purpose rather than a side effect: undefined meaning "silently disabled" is the defect — omitting dev.registry cut programmatic sessions out of cross-session service discovery unless they knew to reconstruct the CLI's registry path themselves. The default now matches the CLI, dev.registry: false is the documented opt-out (mirroring persist: false), and the changeset carries a minor bump for exactly this behavior change on an unstable_-prefixed surface.
One correction to the blast radius: @cloudflare/vite-plugin doesn't consume unstable_startWorker — it builds and manages its own Miniflare instance, including registry wiring — and no package in this monorepo outside wrangler references startWorker at all. The two in-repo call paths (the CLI and the API test harness) are both updated in this diff; external consumers wanting the old behavior pass false.
Makes
unstable_startWorker()join the shared local dev registry by default, the waywrangler devdoes.The gap. The CLI resolves the dev registry to
WRANGLER_REGISTRY_PATHor<global config>/registry(getRegistryPath()) and passes it unless--disable-dev-registry. The programmatic path usedinput.dev.registryraw, so leaving it unset silently disabled cross-session service discovery: astartWorkerworker could not resolve — or be resolved by — other local dev sessions'script_namebindings. The@cloudflare/vite-plugindev path already defaults to the same registry directory (via miniflare'sgetDefaultDevRegistryPath(), whose env override isMINIFLARE_REGISTRY_PATHrather thanWRANGLER_REGISTRY_PATH, but whose default location is the same<global config>/registry), which leftstartWorkeras the odd one out among the dev hosts.The change.
resolveDevConfigmirrors the existingpersistshape: unset applies the CLI's default, an explicit path is preserved verbatim, anddev.registry: falseopts out (the input type widens tostring | false; the resolvedStartDevWorkerOptionsfield staysstring | undefined). The CLI's--disable-dev-registrynow passesfalseexplicitly, andcreateTestHarnesspinsfalseso harness workers stay invisible to the shared registry — both previously relied onundefinedmeaning "disabled". The initial bindings-table print stays keyed on the explicit input, so CLI output is unchanged.Behavior change (the point of the PR): programmatic callers that left
dev.registryunset now join the shared dev registry, likewrangler devsessions do. Callers needing isolation passfalse— the old unset behavior. That includes this repo's own directstartWorker()consumers in fixtures and e2e tests, which now participate in the shared registry the same way the CLI-driven test runs always have;createTestHarnessis the one consumer deliberately pinned tofalse(harness workers must stay invisible). If specific fixtures should stay isolated instead, pinningfalsethere is a one-liner — happy to do that in this PR if preferred. Minor bump onwranglerand@cloudflare/workers-utilsfor the widened input type.Tests: the ConfigController suite pins all three cases — unset resolves to
getRegistryPath(), an explicit path is preserved verbatim,falseresolves toundefined.falseopt-out)StartDevWorkerInputdoc comment documents the new default and the opt-out;unstable_startWorkeris an unstable API. A changeset is included.🤖 Generated with Claude Code