Skip to content

Commit 8809411

Browse files
authored
Part 4️⃣ of removing CfWorkerInit["bindings"] (#12461)
1 parent 734792a commit 8809411

File tree

10 files changed

+316
-242
lines changed

10 files changed

+316
-242
lines changed

.changeset/two-humans-sing.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"@cloudflare/workers-utils": minor
3+
"wrangler": minor
4+
---
5+
6+
Support `type: inherit` bindings when using startWorker()
7+
8+
This is an internal binding type that should not be used by external users of the API

packages/workers-utils/src/config/validation.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export const friendlyBindingNames: Record<
111111
* Friendly names for binding types (keyed by Binding["type"] discriminator).
112112
* These are mostly (but not always) non-plural versions of friendlyBindingNames
113113
*/
114-
export const bindingTypeFriendlyNames: Record<Binding["type"], string> = {
114+
const bindingTypeFriendlyNames: Record<Binding["type"], string> = {
115115
// The 3 binding types below are all rendered as "Environment Variable" to preserve existing behaviour (friendlyBindingNames.vars)
116116
plain_text: "Environment Variable",
117117
secret_text: "Environment Variable",
@@ -146,6 +146,7 @@ export const bindingTypeFriendlyNames: Record<Binding["type"], string> = {
146146
vpc_service: "VPC Service",
147147
media: "Media",
148148
assets: "Assets",
149+
inherit: "Inherited",
149150
} as const;
150151

151152
/**

packages/workers-utils/src/types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,4 +312,5 @@ export type Binding =
312312
| ({ type: "vpc_service" } & BindingOmit<CfVpcService>)
313313
| ({ type: "media" } & BindingOmit<CfMediaBinding>)
314314
| ({ type: `unsafe_${string}` } & Omit<CfUnsafeBinding, "name" | "type">)
315-
| { type: "assets" };
315+
| { type: "assets" }
316+
| { type: "inherit" };

packages/wrangler/src/__tests__/api/startDevWorker/RemoteRuntimeController.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import type {
2424
PreviewTokenExpiredEvent,
2525
StartDevWorkerOptions,
2626
} from "../../../api";
27+
import type { StartDevWorkerInput } from "../../../api/startDevWorker/types";
2728
import type { CfWorkerInit } from "@cloudflare/workers-utils";
2829

2930
// Mock the API modules
@@ -147,7 +148,7 @@ describe("RemoteRuntimeController", () => {
147148
content: "export default { fetch() { return new Response('hello'); } }",
148149
},
149150
modules: [],
150-
bindings: {} as CfWorkerInit["bindings"],
151+
bindings: {} as StartDevWorkerInput["bindings"],
151152
migrations: undefined,
152153
compatibility_date: "2025-11-11",
153154
compatibility_flags: [],

packages/wrangler/src/api/startDevWorker/RemoteRuntimeController.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { realishPrintLogs } from "../../tail/printing";
1919
import { getAccessToken } from "../../user/access";
2020
import { RuntimeController } from "./BaseController";
2121
import { castErrorCause } from "./events";
22-
import { convertBindingsToCfWorkerInitBindings, unwrapHook } from "./utils";
22+
import { unwrapHook } from "./utils";
2323
import type {
2424
CfAccount,
2525
CfPreviewSession,
@@ -257,10 +257,6 @@ export class RemoteRuntimeController extends RuntimeController {
257257
routes: Route[] | undefined,
258258
bundleId: number
259259
) {
260-
const { bindings } = await convertBindingsToCfWorkerInitBindings(
261-
config.bindings
262-
);
263-
264260
// If we received a new `bundleComplete` event before we were able to
265261
// dispatch a `reloadComplete` for this bundle, ignore this bundle.
266262
if (bundleId !== this.#currentBundleId) {
@@ -286,8 +282,7 @@ export class RemoteRuntimeController extends RuntimeController {
286282
}
287283
: undefined,
288284
format: bundle.entry.format,
289-
// TODO: Remove this passthrough
290-
bindings: bindings,
285+
bindings: config.bindings,
291286
compatibilityDate: config.compatibilityDate,
292287
compatibilityFlags: config.compatibilityFlags,
293288
routes,

0 commit comments

Comments
 (0)