-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[wrangler] Remove redundant dev-registry filtering #12974
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| "wrangler": patch | ||
| --- | ||
|
|
||
| Remove redundant dev-registry filtering in `unstable_getMiniflareWorkerOptions` | ||
|
|
||
| The code that rewrote `serviceBindings` and `durableObjects` in `unstable_getMiniflareWorkerOptions` was originally needed to avoid relying on the dev registry for the Workers Vitest pool. Since the dev registry is now entirely defined in Miniflare, this rewriting is no longer necessary — `buildMiniflareBindingOptions` already produces the correct bindings. Removing this code also means `props` on service bindings are no longer dropped. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,7 +4,7 @@ import { | |
| getLocalWorkerdCompatibilityDate, | ||
| getRegistryPath, | ||
| } from "@cloudflare/workers-utils"; | ||
| import { kCurrentWorker, Miniflare } from "miniflare"; | ||
| import { Miniflare } from "miniflare"; | ||
| import { getAssetsOptions, NonExistentAssetsDirError } from "../../../assets"; | ||
| import { readConfig } from "../../../config"; | ||
| import { partitionDurableObjectBindings } from "../../../deployment-bundle/entry"; | ||
|
|
@@ -15,7 +15,6 @@ import { | |
| buildAssetOptions, | ||
| buildMiniflareBindingOptions, | ||
| buildSitesOptions, | ||
| getImageNameFromDOClassName, | ||
| } from "../../../dev/miniflare"; | ||
| import { logger } from "../../../logger"; | ||
| import { getSiteAssetPaths } from "../../../sites"; | ||
|
|
@@ -435,68 +434,6 @@ export function unstable_getMiniflareWorkerOptions( | |
| options?.remoteProxyConnectionString | ||
| ); | ||
|
|
||
| // This function is currently only exported for the Workers Vitest pool. | ||
| // In tests, we don't want to rely on the dev registry, as we can't guarantee | ||
| // which sessions will be running. Instead, we rewrite `serviceBindings` and | ||
| // `durableObjects` to use more traditional Miniflare config expecting the | ||
| // user to define workers with the required names in the `workers` array. | ||
| // These will run the same `workerd` processes as tests. | ||
| const serviceBindings = extractBindingsOfType("service", bindings); | ||
| if (serviceBindings.length > 0) { | ||
| bindingOptions.serviceBindings = Object.fromEntries( | ||
| serviceBindings.map((binding) => { | ||
| const name = | ||
| binding.service === config.name ? kCurrentWorker : binding.service; | ||
| if (options?.remoteProxyConnectionString && binding.remote) { | ||
| return [ | ||
| binding.binding, | ||
| { | ||
| name, | ||
| entrypoint: binding.entrypoint, | ||
| remoteProxyConnectionString: options.remoteProxyConnectionString, | ||
| }, | ||
| ]; | ||
| } | ||
| return [binding.binding, { name, entrypoint: binding.entrypoint }]; | ||
| }) | ||
| ); | ||
| } | ||
| const durableObjectBindings = extractBindingsOfType( | ||
| "durable_object_namespace", | ||
| bindings | ||
| ); | ||
| if (durableObjectBindings.length > 0) { | ||
| type DurableObjectDefinition = NonNullable< | ||
| typeof bindingOptions.durableObjects | ||
| >[string]; | ||
|
|
||
| const classNameToUseSQLite = getDurableObjectClassNameToUseSQLiteMap( | ||
| config.migrations | ||
| ); | ||
|
|
||
| bindingOptions.durableObjects = Object.fromEntries( | ||
| durableObjectBindings.map((binding) => { | ||
| const useSQLite = classNameToUseSQLite.get(binding.class_name); | ||
| return [ | ||
| binding.name, | ||
| { | ||
| className: binding.class_name, | ||
| scriptName: binding.script_name, | ||
| useSQLite, | ||
| container: | ||
| enableContainers && config.containers?.length | ||
| ? getImageNameFromDOClassName({ | ||
| doClassName: binding.class_name, | ||
| containerDOClassNames, | ||
| containerBuildId: options?.containerBuildId, | ||
| }) | ||
| : undefined, | ||
| } satisfies DurableObjectDefinition, | ||
| ]; | ||
| }) | ||
| ); | ||
| } | ||
|
|
||
| const sitesAssetPaths = getSiteAssetPaths(config); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔴 Self-referencing service bindings broken in vitest-pool-workers due to removed kCurrentWorker mapping The removed code mapped self-referencing service bindings ( In the vitest-pool-workers context, the worker's name is overridden to How the old code handled thisThe removed code at the old lines 446-462 did: const name = binding.service === config.name ? kCurrentWorker : binding.service;This ensured that when a worker had a service binding to itself, Miniflare would route it to the current worker via the Prompt for agentsWas this helpful? React with 👍 or 👎 to provide feedback. |
||
| const sitesOptions = buildSitesOptions({ legacyAssetPaths: sitesAssetPaths }); | ||
| const processedAssetOptions = getAssetsOptions( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/bonk this line is redundant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed — the linter catches this via
pnpm checkwhich is already listed. Removed in c11533c.