Skip to content

fix(wrangler): default dev.registry in unstable_startWorker like the CLI#14615

Open
martijnwalraven wants to merge 2 commits into
cloudflare:mainfrom
martijnwalraven:callboard/dev-registry-default
Open

fix(wrangler): default dev.registry in unstable_startWorker like the CLI#14615
martijnwalraven wants to merge 2 commits into
cloudflare:mainfrom
martijnwalraven:callboard/dev-registry-default

Conversation

@martijnwalraven

@martijnwalraven martijnwalraven commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Makes unstable_startWorker() join the shared local dev registry by default, the way wrangler dev does.

The gap. The CLI resolves the dev registry to WRANGLER_REGISTRY_PATH or <global config>/registry (getRegistryPath()) and passes it unless --disable-dev-registry. The programmatic path used input.dev.registry raw, so leaving it unset silently disabled cross-session service discovery: a startWorker worker could not resolve — or be resolved by — other local dev sessions' script_name bindings. The @cloudflare/vite-plugin dev path already defaults to the same registry directory (via miniflare's getDefaultDevRegistryPath(), whose env override is MINIFLARE_REGISTRY_PATH rather than WRANGLER_REGISTRY_PATH, but whose default location is the same <global config>/registry), which left startWorker as the odd one out among the dev hosts.

The change. resolveDevConfig mirrors the existing persist shape: unset applies the CLI's default, an explicit path is preserved verbatim, and dev.registry: false opts out (the input type widens to string | false; the resolved StartDevWorkerOptions field stays string | undefined). The CLI's --disable-dev-registry now passes false explicitly, and createTestHarness pins false so harness workers stay invisible to the shared registry — both previously relied on undefined meaning "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.registry unset now join the shared dev registry, like wrangler dev sessions do. Callers needing isolation pass false — the old unset behavior. That includes this repo's own direct startWorker() consumers in fixtures and e2e tests, which now participate in the shared registry the same way the CLI-driven test runs always have; createTestHarness is the one consumer deliberately pinned to false (harness workers must stay invisible). If specific fixtures should stay isolated instead, pinning false there is a one-liner — happy to do that in this PR if preferred. Minor bump on wrangler and @cloudflare/workers-utils for the widened input type.

Tests: the ConfigController suite pins all three cases — unset resolves to getRegistryPath(), an explicit path is preserved verbatim, false resolves to undefined.


  • Tests
    • Tests included (ConfigController: default / explicit path / false opt-out)
  • Public documentation
    • Documentation not necessary because: the StartDevWorkerInput doc comment documents the new default and the opt-out; unstable_startWorker is an unstable API. A changeset is included.

🤖 Generated with Claude Code


Open in Devin Review

martijnwalraven and others added 2 commits July 8, 2026 23:42
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-bot

changeset-bot Bot commented Jul 8, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: e9f6380

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

This PR includes changesets to release 8 packages
Name Type
wrangler Minor
@cloudflare/workers-utils Minor
@cloudflare/vite-plugin Patch
@cloudflare/vitest-pool-workers Patch
@cloudflare/autoconfig Patch
@cloudflare/cli-shared-helpers Patch
@cloudflare/deploy-helpers Patch
@cloudflare/workers-auth Patch

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

@github-project-automation github-project-automation Bot moved this to Untriaged in workers-sdk Jul 8, 2026
@workers-devprod workers-devprod requested review from a team and edmundhung and removed request for a team July 8, 2026 22:05
@workers-devprod

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • @cloudflare/wrangler
Show detailed file reviewers
  • .changeset/wrangler-dev-registry-default.md: [@cloudflare/wrangler]
  • packages/workers-utils/src/types.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/tests/api/startDevWorker/ConfigController.test.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/api/startDevWorker/ConfigController.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/api/startDevWorker/types.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/api/test-harness.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/dev/start-dev.ts: [@cloudflare/wrangler]

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Devin Review found 1 potential issue.

Open in Devin Review

Comment on lines +117 to +120
const devRegistryPath =
input.dev?.registry === false
? undefined
: (input.dev?.registry ?? getRegistryPath());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔍 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.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Untriaged

Development

Successfully merging this pull request may close these issues.

2 participants