wrangler 4.30.0 → 4.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -605,11 +605,7 @@
605
605
  },
606
606
  "service": {
607
607
  "type": "string",
608
- "description": "The name of the service."
609
- },
610
- "environment": {
611
- "type": "string",
612
- "description": "The environment of the service (e.g. production, staging, etc)."
608
+ "description": "The name of the service. To bind to a worker in a specific environment, you should use the format `<worker_name>-<environment_name>`."
613
609
  },
614
610
  "entrypoint": {
615
611
  "type": "string",
@@ -1611,11 +1607,7 @@
1611
1607
  },
1612
1608
  "service": {
1613
1609
  "type": "string",
1614
- "description": "The name of the service."
1615
- },
1616
- "environment": {
1617
- "type": "string",
1618
- "description": "The environment of the service (e.g. production, staging, etc)."
1610
+ "description": "The name of the service. To bind to a worker in a specific environment, you should use the format `<worker_name>-<environment_name>`."
1619
1611
  },
1620
1612
  "entrypoint": {
1621
1613
  "type": "string",
@@ -2390,19 +2382,22 @@
2390
2382
  "default": "dev"
2391
2383
  },
2392
2384
  "rollout_step_percentage": {
2393
- "type": "number",
2394
- "description": "How a rollout should be done, defining the size of it",
2395
- "default": 25
2396
- },
2397
- "rollout_kind": {
2398
- "type": "string",
2399
- "enum": [
2400
- "full_auto",
2401
- "none",
2402
- "full_manual"
2385
+ "anyOf": [
2386
+ {
2387
+ "type": "number"
2388
+ },
2389
+ {
2390
+ "type": "array",
2391
+ "items": {
2392
+ "type": "number"
2393
+ }
2394
+ }
2403
2395
  ],
2404
- "description": "How a rollout should be created. It supports the following modes: - full_auto: The container application will be rolled out fully automatically. - none: The container application won't have a roll out or update. - manual: The container application will be rollout fully by manually actioning progress steps.",
2405
- "default": "full_auto"
2396
+ "description": "Configures what percentage of instances should be updated at each step of a rollout. You can specify this as a single number, or an array of numbers.\n\nIf this is a single number, each step will progress by that percentage. The options are 5, 10, 20, 25, 50 or 100.\n\nIf this is an array, each step specifies the cumulative rollout progress. The final step must be 100.\n\nThis can be overridden adhoc by deploying with the `--containers-rollout=immediate` flag, which will roll out to 100% of instances in one step.",
2397
+ "default": [
2398
+ 10,
2399
+ 100
2400
+ ]
2406
2401
  },
2407
2402
  "rollout_active_grace_period": {
2408
2403
  "type": "number",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wrangler",
3
- "version": "4.30.0",
3
+ "version": "4.32.0",
4
4
  "description": "Command-line interface for all things Cloudflare Workers",
5
5
  "keywords": [
6
6
  "wrangler",
@@ -54,15 +54,16 @@
54
54
  "esbuild": "0.25.4",
55
55
  "path-to-regexp": "6.3.0",
56
56
  "unenv": "2.0.0-rc.19",
57
- "workerd": "1.20250813.0",
57
+ "workerd": "1.20250816.0",
58
58
  "@cloudflare/kv-asset-handler": "0.4.0",
59
- "@cloudflare/unenv-preset": "2.6.1",
60
- "miniflare": "4.20250813.1"
59
+ "@cloudflare/unenv-preset": "2.6.2",
60
+ "miniflare": "4.20250816.1"
61
61
  },
62
62
  "devDependencies": {
63
63
  "@aws-sdk/client-s3": "^3.721.0",
64
+ "@cloudflare/jsrpc": "link:../../vendor/jsrpc",
64
65
  "@cloudflare/types": "6.18.4",
65
- "@cloudflare/workers-types": "^4.20250813.0",
66
+ "@cloudflare/workers-types": "^4.20250816.0",
66
67
  "@cspotcode/source-map-support": "0.8.1",
67
68
  "@iarna/toml": "^3.0.0",
68
69
  "@sentry/node": "^7.86.0",
@@ -137,14 +138,14 @@
137
138
  "xxhash-wasm": "^1.0.1",
138
139
  "yargs": "^17.7.2",
139
140
  "@cloudflare/cli": "1.1.1",
140
- "@cloudflare/containers-shared": "0.2.10",
141
- "@cloudflare/pages-shared": "^0.13.63",
142
- "@cloudflare/workers-shared": "0.18.5",
143
141
  "@cloudflare/workers-tsconfig": "0.0.0",
144
- "@cloudflare/eslint-config-worker": "1.1.0"
142
+ "@cloudflare/eslint-config-worker": "1.1.0",
143
+ "@cloudflare/pages-shared": "^0.13.65",
144
+ "@cloudflare/workers-shared": "0.18.6",
145
+ "@cloudflare/containers-shared": "0.2.10"
145
146
  },
146
147
  "peerDependencies": {
147
- "@cloudflare/workers-types": "^4.20250813.0"
148
+ "@cloudflare/workers-types": "^4.20250816.0"
148
149
  },
149
150
  "peerDependenciesMeta": {
150
151
  "@cloudflare/workers-types": {
@@ -0,0 +1,133 @@
1
+ import { newWorkersRpcResponse } from "@cloudflare/jsrpc";
2
+ import { EmailMessage } from "cloudflare:email";
3
+
4
+ interface Env extends Record<string, unknown> {}
5
+
6
+ class BindingNotFoundError extends Error {
7
+ constructor(name?: string) {
8
+ super(`Binding ${name ? `"${name}"` : ""} not found`);
9
+ }
10
+ }
11
+
12
+ /**
13
+ * For most bindings, we expose them as
14
+ * - RPC stubs directly to @cloudflare/jsrpc, or
15
+ * - HTTP based fetchers
16
+ * However, there are some special cases:
17
+ * - SendEmail bindings need to take EmailMessage as their first parameter,
18
+ * which is not serialisable. As such, we reconstruct it before sending it
19
+ * on to the binding. See packages/miniflare/src/workers/email/email.worker.ts
20
+ * - Dispatch Namespace bindings have a synchronous .get() method. Since we
21
+ * can't emulate that over an async boundary, we mock it locally and _actually_
22
+ * perform the .get() remotely at the first appropriate async point. See
23
+ * packages/miniflare/src/workers/dispatch-namespace/dispatch-namespace.worker.ts
24
+ *
25
+ * getExposedJSRPCBinding() and getExposedFetcher() perform the logic for figuring out
26
+ * which binding is being accessed, dependending on the request. Note: Both have logic
27
+ * for dispatch namespaces, because dispatch namespaces can use both fetch or RPC depending
28
+ * on context.
29
+ */
30
+
31
+ function getExposedJSRPCBinding(request: Request, env: Env) {
32
+ const url = new URL(request.url);
33
+ const bindingName = url.searchParams.get("MF-Binding");
34
+ if (!bindingName) {
35
+ throw new BindingNotFoundError();
36
+ }
37
+
38
+ const targetBinding = env[bindingName];
39
+ if (!targetBinding) {
40
+ throw new BindingNotFoundError(bindingName);
41
+ }
42
+
43
+ if (targetBinding.constructor.name === "SendEmail") {
44
+ return {
45
+ async send(e: ForwardableEmailMessage) {
46
+ // @ts-expect-error EmailMessage::raw is defined in packages/miniflare/src/workers/email/email.worker.ts
47
+ const message = new EmailMessage(e.from, e.to, e["EmailMessage::raw"]);
48
+ return (targetBinding as SendEmail).send(message);
49
+ },
50
+ };
51
+ }
52
+
53
+ if (url.searchParams.has("MF-Dispatch-Namespace-Options")) {
54
+ const { name, args, options } = JSON.parse(
55
+ url.searchParams.get("MF-Dispatch-Namespace-Options")!
56
+ );
57
+ return (targetBinding as DispatchNamespace).get(name, args, options);
58
+ }
59
+
60
+ return targetBinding;
61
+ }
62
+
63
+ function getExposedFetcher(request: Request, env: Env) {
64
+ const bindingName = request.headers.get("MF-Binding");
65
+ if (!bindingName) {
66
+ throw new BindingNotFoundError();
67
+ }
68
+
69
+ const targetBinding = env[bindingName];
70
+ if (!targetBinding) {
71
+ throw new BindingNotFoundError(bindingName);
72
+ }
73
+
74
+ // Special case the Dispatch Namespace binding because it has a top-level synchronous .get() call
75
+ const dispatchNamespaceOptions = request.headers.get(
76
+ "MF-Dispatch-Namespace-Options"
77
+ );
78
+ if (dispatchNamespaceOptions) {
79
+ const { name, args, options } = JSON.parse(dispatchNamespaceOptions);
80
+ return (targetBinding as DispatchNamespace).get(name, args, options);
81
+ }
82
+ return targetBinding as Fetcher;
83
+ }
84
+
85
+ /**
86
+ * This Worker can proxy two types of remote binding:
87
+ * 1. "raw" bindings, where this Worker has been configured to pass through the raw
88
+ * fetch from a local workerd instance to the relevant binding
89
+ * 2. JSRPC bindings, where this Worker uses @cloudflare/jsrpc to proxy RPC
90
+ * communication in userland. This is always over a WebSocket connection
91
+ */
92
+ function isJSRPCBinding(request: Request): boolean {
93
+ const url = new URL(request.url);
94
+ return request.headers.has("Upgrade") && url.searchParams.has("MF-Binding");
95
+ }
96
+
97
+ export default {
98
+ async fetch(request, env) {
99
+ try {
100
+ if (isJSRPCBinding(request)) {
101
+ return newWorkersRpcResponse(
102
+ request,
103
+ getExposedJSRPCBinding(request, env)
104
+ );
105
+ } else {
106
+ const fetcher = getExposedFetcher(request, env);
107
+ const originalHeaders = new Headers();
108
+ for (const [name, value] of request.headers) {
109
+ if (name.startsWith("mf-header-")) {
110
+ originalHeaders.set(name.slice("mf-header-".length), value);
111
+ } else if (name === "upgrade") {
112
+ // The `Upgrade` header needs to be special-cased to prevent:
113
+ // TypeError: Worker tried to return a WebSocket in a response to a request which did not contain the header "Upgrade: websocket"
114
+ originalHeaders.set(name, value);
115
+ }
116
+ }
117
+
118
+ return fetcher.fetch(
119
+ request.headers.get("MF-URL") ?? "http://example.com",
120
+ new Request(request, {
121
+ redirect: "manual",
122
+ headers: originalHeaders,
123
+ })
124
+ );
125
+ }
126
+ } catch (e) {
127
+ if (e instanceof BindingNotFoundError) {
128
+ return new Response(e.message, { status: 400 });
129
+ }
130
+ return new Response((e as Error).message, { status: 500 });
131
+ }
132
+ },
133
+ } satisfies ExportedHandler<Env>;
@@ -1,4 +1,4 @@
1
1
  {
2
- "main": "./index.ts",
2
+ "main": "./ProxyServerWorker.ts",
3
3
  "compatibility_date": "2025-04-28",
4
4
  }