Skip to content

Part 2️⃣ of removing CfWorkerInit["bindings"]#12455

Merged
penalosa merged 7 commits intomainfrom
penalosa/granular-refactor-2
Feb 9, 2026
Merged

Part 2️⃣ of removing CfWorkerInit["bindings"]#12455
penalosa merged 7 commits intomainfrom
penalosa/granular-refactor-2

Conversation

@penalosa
Copy link
Copy Markdown
Contributor

@penalosa penalosa commented Feb 6, 2026

Part 2 of landing #12151 in stages. This part:

  • Modifies LocalRuntimeController so that it no longer converts StartDevWorkerOptions["bindings"] -> CfWorkerInit["bindings"] -> Miniflare, it just goes straight from StartDevWorkerOptions["bindings"] to Miniflare's config.

  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
    • Additional testing not necessary because: covered by existing tests, which have not been changed.
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: internal refactor

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


Open with Devin

@penalosa penalosa requested a review from a team as a code owner February 6, 2026 20:31
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Feb 6, 2026

⚠️ No Changeset found

Latest commit: a3eab05

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.

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 Feb 6, 2026
@penalosa penalosa changed the base branch from main to penalosa/granular-refactor February 6, 2026 20:32
"version_metadata",
bindings
);
const fetchers = extractBindingsOfType("fetcher", bindings);
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.

This is messy for now, but a followup will eventually allow Miniflare's config to take a similar structure, removing a lot of this conversion logic

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 6 additional findings.

Open in Devin Review

Comment on lines -484 to -500
// In remote `dev`, we make folks use a separate kv namespace called
// `preview_id` instead of `id` so that they don't
// break production data. So here we check that a `preview_id`
// has actually been configured.
// This whole block of code will be obsoleted in the future
// when we have copy-on-write for previews on edge workers.
if (!preview_id && !local) {
// TODO: This error has to be a _lot_ better, ideally just asking
// to create a preview namespace for the user automatically
throw new UserError(
`In development, you should use a separate kv namespace than the one you'd use in production. Please create a new kv namespace with "wrangler kv namespace create <name> --preview" and add its id as preview_id to the kv_namespace "${binding}" in your ${configFileName(configParam.configPath)} file`,
{
telemetryMessage:
"no preview kv namespace configured in remote dev",
}
); // Ugh, I really don't like this message very much
}
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.

This error (and the below duplicates of it) has been removed. We no longer recommend remote mode dev, and will be removing preview IDs entirely eventually.

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.

Is this removal an essential part of this restructure?
It feels like this is a significant change to behaviour in what should be a no-op refactor?

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.

It's not essential, but given I was touching this area of the codebase anyway (and it's a simple enough change) it seemed worth doing. This logic throws an error if the user hasn't specified a preview ID when using KV or R2 bindings and wrangler dev --remote. Crucially, it doesn't display when using remote bindings, which is what we expect most people to use going forward. This error made sense in a world where wrangler dev connected to production resources by default, but since you now have to opt-in with remote = true or --remote it's much clearer to the user that that is happening, and if they want to they can use alternatives like environments.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Feb 6, 2026

create-cloudflare

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

@cloudflare/kv-asset-handler

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

miniflare

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

@cloudflare/pages-shared

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

@cloudflare/unenv-preset

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

@cloudflare/vite-plugin

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

@cloudflare/vitest-pool-workers

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

@cloudflare/workers-editor-shared

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

@cloudflare/workers-utils

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

wrangler

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

commit: a3eab05

Comment on lines +688 to +698
export function getFlatBindings(
configParam: Config,
env: string | undefined,
envFiles: string[] | undefined,
local: boolean,
args: AdditionalDevProps
): StartDevWorkerInput["bindings"] {
const bindings = getBindings(configParam, env, envFiles, local, args);
return convertCfWorkerInitBindingsToBindings(bindings);
}

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.

This is messy and will be removed in part 3️⃣ or 4️⃣

@penalosa penalosa force-pushed the penalosa/granular-refactor-2 branch from 95db292 to a72b4a0 Compare February 6, 2026 21:10
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 found 1 new potential issue.

View 9 additional findings in Devin Review.

Open in Devin Review

Comment thread packages/wrangler/src/dev/miniflare/index.ts
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 found 1 new potential issue.

View 12 additional findings in Devin Review.

Open in Devin Review

Comment thread packages/wrangler/src/dev/miniflare/index.ts
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 found 1 new potential issue.

View 13 additional findings in Devin Review.

Open in Devin Review

Comment thread packages/wrangler/src/dev/miniflare/index.ts
Base automatically changed from penalosa/granular-refactor to main February 9, 2026 13:32
@penalosa penalosa force-pushed the penalosa/granular-refactor-2 branch from 909f63e to 9c06fb4 Compare February 9, 2026 13:41
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 found 1 new potential issue.

View 17 additional findings in Devin Review.

Open in Devin Review

Comment thread packages/wrangler/src/dev/miniflare/index.ts
@vicb vicb self-requested a review February 9, 2026 14:05
penalosa and others added 2 commits February 9, 2026 14:19
Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
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.

Just a few comments to resolve before I approve.

Comment on lines +243 to +246
const workflowBindings = extractBindingsOfType("workflow", bindings);
for (const workflow of workflowBindings) {
delete bindings?.[workflow.binding];
}
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.

Alternatively, we could avoid more work by passing an ignoreBindingTypes param to the getFlatBindings() and so down to convertCfWorkerInitBindingsToBindings() which would mean it would not even compute these in the first place?

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.

Potentially in a followup, yes? convertCfWorkerInitBindingsToBindings() will be entirely removed from the codebase in part 6, which means we won't really be doing any duplicate work over the current state of the codebase.

options?.remoteProxyConnectionString
);

// This function is currently only exported for the Workers Vitest pool.
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.

Outside of this PR but this comment is no longer valid. The vite-plugin calls this function too. Does that also want to avoid using the dev-registry?

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.

I don't think this code actually does anything anymore, since the dev registry is entirely defined in Miniflare. I'll remove it in a followup PR

Comment on lines -484 to -500
// In remote `dev`, we make folks use a separate kv namespace called
// `preview_id` instead of `id` so that they don't
// break production data. So here we check that a `preview_id`
// has actually been configured.
// This whole block of code will be obsoleted in the future
// when we have copy-on-write for previews on edge workers.
if (!preview_id && !local) {
// TODO: This error has to be a _lot_ better, ideally just asking
// to create a preview namespace for the user automatically
throw new UserError(
`In development, you should use a separate kv namespace than the one you'd use in production. Please create a new kv namespace with "wrangler kv namespace create <name> --preview" and add its id as preview_id to the kv_namespace "${binding}" in your ${configFileName(configParam.configPath)} file`,
{
telemetryMessage:
"no preview kv namespace configured in remote dev",
}
); // Ugh, I really don't like this message very much
}
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.

Is this removal an essential part of this restructure?
It feels like this is a significant change to behaviour in what should be a no-op refactor?

@github-project-automation github-project-automation Bot moved this from Untriaged to Approved in workers-sdk Feb 9, 2026
@penalosa penalosa merged commit 000cefa into main Feb 9, 2026
47 of 48 checks passed
@github-project-automation github-project-automation Bot moved this from Approved to Done in workers-sdk Feb 9, 2026
@penalosa penalosa deleted the penalosa/granular-refactor-2 branch February 9, 2026 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants