Skip to content

[miniflare] Register workers in the dev registry by default - #15061

Merged
dario-piotrowicz merged 1 commit into
mainfrom
edmundhung/register-workers-by-default
Aug 6, 2026
Merged

[miniflare] Register workers in the dev registry by default#15061
dario-piotrowicz merged 1 commit into
mainfrom
edmundhung/register-workers-by-default

Conversation

@edmundhung

@edmundhung edmundhung commented Aug 6, 2026

Copy link
Copy Markdown
Member

Follow-up to #15040.

This keeps named workers advertised in the dev registry by default while allowing callers to opt out with unsafeRegisterWorker: false. It removes all now-redundant unsafeRegisterWorker: true options and updates the existing changeset to classify the option as a non-breaking minor feature.

The Vite plugin explicitly opts its router, asset, and proxy workers out, ensuring that only user workers are advertised during dev and preview.

The dev registry test now verifies both default registration and the explicit false opt-out.


  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
    • Additional testing not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: This internal Miniflare option is documented in the package README.

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

@changeset-bot

changeset-bot Bot commented Aug 6, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: adfc95b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes changesets to release 8 packages
Name Type
miniflare Minor
@cloudflare/deploy-helpers Patch
@cloudflare/pages-shared Patch
@cloudflare/remote-bindings Patch
@cloudflare/runtime-types Patch
@cloudflare/vite-plugin Patch
@cloudflare/vitest-pool-workers Patch
wrangler Patch

Click here to learn what changesets are, and how to add one.

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

@github-project-automation github-project-automation Bot moved this to Untriaged in workers-sdk Aug 6, 2026
@workers-devprod
workers-devprod requested review from a team and dario-piotrowicz and removed request for a team August 6, 2026 14:53
@workers-devprod

workers-devprod commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • ✅ @cloudflare/wrangler
Show detailed file reviewers

@ask-bonk

ask-bonk Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

I'm Bonk, and I've done a quick review of your PR.

Summary: this flips unsafeRegisterWorker to default true so named Miniflare workers are advertised in the dev registry by default, and removes the now-redundant explicit unsafeRegisterWorker: true call sites.

Behavioral regression (high severity): internal Vite plugin workers will now be advertised.

The Vite plugin's dev Miniflare instance (packages/vite-plugin-cloudflare/src/miniflare-options.ts) sets unsafeDevRegistryPath: getDefaultDevRegistryPath() (line 560) and its worker list is workers: [...assetWorkers, ...externalWorkers, ...userWorkers] (line 588). The assetWorkers array contains three internal named workers that never set unsafeRegisterWorker:

  • ROUTER_WORKER_NAME (line 158)
  • ASSET_WORKER_NAME (line 182)
  • VITE_PROXY_WORKER_NAME (line 311)

Previously these relied on the false default and were NOT advertised. With the default now true, the registration loop in packages/miniflare/src/index.ts:2705 (if (!workerOpts.core.name || !workerOpts.core.unsafeRegisterWorker) { continue; }) will start advertising all three, since they are named and live in the same instance as unsafeDevRegistryPath.

This is exactly the scenario #15040's changeset described wanting to avoid — "advertise user workers without exposing internal or external workers." Only the removed unsafeRegisterWorker: true on the user worker (line 357) was previously needed; the internal workers depended on the old false default.

Fix: explicitly opt the internal workers out. For each of the three assetWorkers entries, add:

			name: ROUTER_WORKER_NAME,
			unsafeRegisterWorker: false,

(and likewise unsafeRegisterWorker: false next to ASSET_WORKER_NAME and VITE_PROXY_WORKER_NAME).

Note: the getMiniflareOptionsFromConfig / getPreviewMiniflareOptions / wrangler dev paths only removed explicit trues on user workers, so those are unaffected. The dev path's internal asset/router/proxy workers are the only regression I found.

devin-ai-integration[bot]

This comment was marked as resolved.

@ask-bonk

ask-bonk Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Posted the review as a top-level comment on PR #15061 (inline suggestions were rejected with 422 because the target lines aren't in the diff).

Key finding: The Vite plugin's dev Miniflare instance (miniflare-options.ts) sets unsafeDevRegistryPath and includes three internal named workers (ROUTER_WORKER_NAME, ASSET_WORKER_NAME, VITE_PROXY_WORKER_NAME) that never set unsafeRegisterWorker. With the default flipping from false to true, these internal workers will now be advertised in the dev registry — the exact behavior #15040 aimed to prevent. Recommended they be explicitly opted out with unsafeRegisterWorker: false.

github run

@pkg-pr-new

pkg-pr-new Bot commented Aug 6, 2026

Copy link
Copy Markdown
@cloudflare/autoconfig

npm i https://pkg.pr.new/@cloudflare/autoconfig@15061

@cloudflare/build-output-utils

npm i https://pkg.pr.new/@cloudflare/build-output-utils@15061

@cloudflare/config

npm i https://pkg.pr.new/@cloudflare/config@15061

create-cloudflare

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

@cloudflare/deploy-helpers

npm i https://pkg.pr.new/@cloudflare/deploy-helpers@15061

@cloudflare/kv-asset-handler

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

miniflare

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

@cloudflare/pages-functions

npm i https://pkg.pr.new/@cloudflare/pages-functions@15061

@cloudflare/pages-shared

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

@cloudflare/unenv-preset

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

@cloudflare/vite-plugin

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

@cloudflare/vitest-pool-workers

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

@cloudflare/workers-auth

npm i https://pkg.pr.new/@cloudflare/workers-auth@15061

@cloudflare/workers-editor-shared

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

@cloudflare/workers-utils

npm i https://pkg.pr.new/@cloudflare/workers-utils@15061

wrangler

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

commit: adfc95b

@edmundhung
edmundhung force-pushed the edmundhung/register-workers-by-default branch 3 times, most recently from d3be37c to 9d7509b Compare August 6, 2026 15:13

@dario-piotrowicz dario-piotrowicz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM 🙂

@workers-devprod workers-devprod 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.

Codeowners reviews satisfied

@github-project-automation github-project-automation Bot moved this from Untriaged to Approved in workers-sdk Aug 6, 2026
@edmundhung
edmundhung force-pushed the edmundhung/register-workers-by-default branch from 9d7509b to adfc95b Compare August 6, 2026 15:29
@dario-piotrowicz
dario-piotrowicz merged commit 386ff6e into main Aug 6, 2026
163 of 180 checks passed
@dario-piotrowicz
dario-piotrowicz deleted the edmundhung/register-workers-by-default branch August 6, 2026 17:40
@github-project-automation github-project-automation Bot moved this from Approved to Done in workers-sdk Aug 6, 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.

3 participants