Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/two-humans-sing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@cloudflare/workers-utils": minor
"wrangler": minor
---

Support `type: inherit` bindings when using startWorker()

This is an internal binding type that should not be used by external users of the API
3 changes: 2 additions & 1 deletion packages/workers-utils/src/config/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export const friendlyBindingNames: Record<
* Friendly names for binding types (keyed by Binding["type"] discriminator).
* These are mostly (but not always) non-plural versions of friendlyBindingNames
*/
export const bindingTypeFriendlyNames: Record<Binding["type"], string> = {
const bindingTypeFriendlyNames: Record<Binding["type"], string> = {
// The 3 binding types below are all rendered as "Environment Variable" to preserve existing behaviour (friendlyBindingNames.vars)
plain_text: "Environment Variable",
secret_text: "Environment Variable",
Expand Down Expand Up @@ -146,6 +146,7 @@ export const bindingTypeFriendlyNames: Record<Binding["type"], string> = {
vpc_service: "VPC Service",
media: "Media",
assets: "Assets",
inherit: "Inherited",
} as const;

/**
Expand Down
3 changes: 2 additions & 1 deletion packages/workers-utils/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,4 +312,5 @@ export type Binding =
| ({ type: "vpc_service" } & BindingOmit<CfVpcService>)
| ({ type: "media" } & BindingOmit<CfMediaBinding>)
| ({ type: `unsafe_${string}` } & Omit<CfUnsafeBinding, "name" | "type">)
| { type: "assets" };
| { type: "assets" }
| { type: "inherit" };
Copy link
Member

Choose a reason for hiding this comment

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

Binding is a public facing API, so wouldn't this change require a changeset?

Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import type {
PreviewTokenExpiredEvent,
StartDevWorkerOptions,
} from "../../../api";
import type { StartDevWorkerInput } from "../../../api/startDevWorker/types";
import type { CfWorkerInit } from "@cloudflare/workers-utils";

// Mock the API modules
Expand Down Expand Up @@ -147,7 +148,7 @@ describe("RemoteRuntimeController", () => {
content: "export default { fetch() { return new Response('hello'); } }",
},
modules: [],
bindings: {} as CfWorkerInit["bindings"],
bindings: {} as StartDevWorkerInput["bindings"],
migrations: undefined,
compatibility_date: "2025-11-11",
compatibility_flags: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { realishPrintLogs } from "../../tail/printing";
import { getAccessToken } from "../../user/access";
import { RuntimeController } from "./BaseController";
import { castErrorCause } from "./events";
import { convertBindingsToCfWorkerInitBindings, unwrapHook } from "./utils";
import { unwrapHook } from "./utils";
import type {
CfAccount,
CfPreviewSession,
Expand Down Expand Up @@ -257,10 +257,6 @@ export class RemoteRuntimeController extends RuntimeController {
routes: Route[] | undefined,
bundleId: number
) {
const { bindings } = await convertBindingsToCfWorkerInitBindings(
config.bindings
);

// If we received a new `bundleComplete` event before we were able to
// dispatch a `reloadComplete` for this bundle, ignore this bundle.
if (bundleId !== this.#currentBundleId) {
Expand All @@ -286,8 +282,7 @@ export class RemoteRuntimeController extends RuntimeController {
}
: undefined,
format: bundle.entry.format,
// TODO: Remove this passthrough
bindings: bindings,
bindings: config.bindings,
compatibilityDate: config.compatibilityDate,
compatibilityFlags: config.compatibilityFlags,
routes,
Expand Down
Loading
Loading