wrangler 4.129.0 → 4.130.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.
@@ -4106,16 +4106,16 @@
4106
4106
  "additionalProperties": false,
4107
4107
  "properties": {
4108
4108
  "logpush": {
4109
- "$ref": "#/definitions/interface-769040647-11843-22205-769040647-0-567642004818536"
4109
+ "$ref": "#/definitions/interface-769040647-12589-22951-769040647-0-575102004818536"
4110
4110
  },
4111
4111
  "observability": {
4112
- "$ref": "#/definitions/interface-769040647-11843-22205-769040647-0-567642004818536"
4112
+ "$ref": "#/definitions/interface-769040647-12589-22951-769040647-0-575102004818536"
4113
4113
  },
4114
4114
  "limits": {
4115
- "$ref": "#/definitions/interface-769040647-11843-22205-769040647-0-567642004818536"
4115
+ "$ref": "#/definitions/interface-769040647-12589-22951-769040647-0-575102004818536"
4116
4116
  },
4117
4117
  "cache": {
4118
- "$ref": "#/definitions/interface-769040647-11843-22205-769040647-0-567642004818536"
4118
+ "$ref": "#/definitions/interface-769040647-12589-22951-769040647-0-575102004818536"
4119
4119
  },
4120
4120
  "define": {
4121
4121
  "type": "object",
@@ -5419,7 +5419,7 @@
5419
5419
  "description": "Configuration for Worker Previews.\n\nThis defines the settings used when creating Preview deployments. Previews are branches of your Worker's main instance used to test features during feature development outside of production.\n\nThe `previews` block contains any intentionally divergent configuration intended solely for Previews, including:\n- All non-inheritable properties (environment variables and bindings like KV, D1, R2, etc.)\n- Select inheritable properties: `logpush`, `observability`, `limits`, `cache`",
5420
5420
  "markdownDescription": "Configuration for Worker Previews.\n\nThis defines the settings used when creating Preview deployments.\nPreviews are branches of your Worker's main instance used to test features\nduring feature development outside of production.\n\nThe `previews` block contains any intentionally divergent configuration intended solely for Previews, including:\n- All non-inheritable properties (environment variables and bindings like KV, D1, R2, etc.)\n- Select inheritable properties: `logpush`, `observability`, `limits`, `cache`"
5421
5421
  },
5422
- "interface-769040647-11843-22205-769040647-0-567642004818536": {
5422
+ "interface-769040647-12589-22951-769040647-0-575102004818536": {
5423
5423
  "type": "object",
5424
5424
  "properties": {
5425
5425
  "name": {
@@ -6038,6 +6038,11 @@
6038
6038
  "description": "The class name of the Durable Object the container is connected to.",
6039
6039
  "markdownDescription": "The class name of the Durable Object the container is connected to."
6040
6040
  },
6041
+ "observability": {
6042
+ "$ref": "#/definitions/ContainerObservability",
6043
+ "description": "Specify the observability behavior of this container application.\n\nWhen set, this overrides the root `observability` config for this container.",
6044
+ "markdownDescription": "Specify the observability behavior of this container application.\n\nWhen set, this overrides the root `observability` config for this container."
6045
+ },
6041
6046
  "scheduling_policy": {
6042
6047
  "type": "string",
6043
6048
  "enum": [
@@ -6229,6 +6234,36 @@
6229
6234
  "required": [
6230
6235
  "image"
6231
6236
  ],
6237
+ "additionalProperties": false
6238
+ },
6239
+ "ContainerObservability": {
6240
+ "type": "object",
6241
+ "properties": {
6242
+ "enabled": {
6243
+ "type": "boolean",
6244
+ "description": "If observability is enabled for this container application",
6245
+ "markdownDescription": "If observability is enabled for this container application"
6246
+ },
6247
+ "logs": {
6248
+ "type": "object",
6249
+ "properties": {
6250
+ "enabled": {
6251
+ "type": "boolean"
6252
+ }
6253
+ },
6254
+ "additionalProperties": false
6255
+ },
6256
+ "target_instance_percentage": {
6257
+ "type": "number",
6258
+ "description": "Percentage of instances to target with application-level observability hot reloads. Mutually exclusive with `target_instance_count`.",
6259
+ "markdownDescription": "Percentage of instances to target with application-level observability hot reloads.\nMutually exclusive with `target_instance_count`."
6260
+ },
6261
+ "target_instance_count": {
6262
+ "type": "number",
6263
+ "description": "Number of instances to target with application-level observability hot reloads. Mutually exclusive with `target_instance_percentage`.",
6264
+ "markdownDescription": "Number of instances to target with application-level observability hot reloads.\nMutually exclusive with `target_instance_percentage`."
6265
+ }
6266
+ },
6232
6267
  "additionalProperties": false,
6233
6268
  "description": "Configuration for a container application",
6234
6269
  "markdownDescription": "Configuration for a container application"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wrangler",
3
- "version": "4.129.0",
3
+ "version": "4.130.0",
4
4
  "description": "Command-line interface for all things Cloudflare Workers",
5
5
  "keywords": [
6
6
  "assembly",
@@ -66,17 +66,17 @@
66
66
  "esbuild": "0.28.1",
67
67
  "path-to-regexp": "6.3.0",
68
68
  "unenv": "2.0.0-rc.24",
69
- "workerd": "1.20260903.1",
70
- "@cloudflare/kv-asset-handler": "0.5.0",
71
- "miniflare": "5.20260903.0-alpha",
72
- "@cloudflare/unenv-preset": "2.16.1"
69
+ "workerd": "1.20260908.1",
70
+ "miniflare": "5.20260908.0-alpha",
71
+ "@cloudflare/unenv-preset": "2.16.1",
72
+ "@cloudflare/kv-asset-handler": "0.5.0"
73
73
  },
74
74
  "devDependencies": {
75
75
  "@aws-sdk/client-s3": "^3.721.0",
76
76
  "@aws-sdk/s3-request-presigner": "^3.721.0",
77
77
  "@bomb.sh/tab": "^0.0.12",
78
78
  "@cloudflare/types": "6.18.4",
79
- "@cloudflare/workers-types": "^5.20260903.1",
79
+ "@cloudflare/workers-types": "^5.20260908.1",
80
80
  "@cspotcode/source-map-support": "0.8.1",
81
81
  "@netlify/build-info": "10.5.1",
82
82
  "@sentry/node": "^7.86.0",
@@ -156,25 +156,25 @@
156
156
  "yaml": "^2.8.1",
157
157
  "yargs": "^17.7.2",
158
158
  "zod": "4.4.3",
159
- "@cloudflare/autoconfig": "0.4.2",
160
- "@cloudflare/cli-shared-helpers": "0.1.27",
161
- "@cloudflare/build-output-utils": "0.4.0",
162
- "@cloudflare/config": "0.10.0",
159
+ "@cloudflare/autoconfig": "0.4.3",
160
+ "@cloudflare/build-output-utils": "0.4.1",
161
+ "@cloudflare/cli-shared-helpers": "0.1.28",
162
+ "@cloudflare/deploy-helpers": "0.10.3",
163
+ "@cloudflare/config": "0.11.0",
163
164
  "@cloudflare/containers-shared": "0.16.0",
164
- "@cloudflare/deploy-helpers": "0.10.1",
165
+ "@cloudflare/pages-shared": "^0.13.178",
166
+ "@cloudflare/runtime-types": "0.0.23",
165
167
  "@cloudflare/pages-functions": "0.1.0",
166
- "@cloudflare/pages-shared": "^0.13.176",
167
- "@cloudflare/workers-auth": "0.6.8",
168
- "@cloudflare/workflows-shared": "0.13.0",
169
- "@cloudflare/shared-ast-primitives": "1.1.0",
170
- "@cloudflare/workers-utils": "0.36.0",
171
- "@cloudflare/runtime-types": "0.0.21",
172
- "@cloudflare/remote-bindings": "0.0.19",
168
+ "@cloudflare/remote-bindings": "0.0.21",
169
+ "@cloudflare/workers-auth": "0.6.10",
173
170
  "@cloudflare/workers-shared": "0.19.9",
174
- "@cloudflare/workers-tsconfig": "0.0.0"
171
+ "@cloudflare/shared-ast-primitives": "1.1.0",
172
+ "@cloudflare/workers-tsconfig": "0.0.0",
173
+ "@cloudflare/workers-utils": "0.37.0",
174
+ "@cloudflare/workflows-shared": "0.13.0"
175
175
  },
176
176
  "peerDependencies": {
177
- "@cloudflare/workers-types": "^5.20260903.1"
177
+ "@cloudflare/workers-types": "^5.20260908.1"
178
178
  },
179
179
  "peerDependenciesMeta": {
180
180
  "@cloudflare/workers-types": {
@@ -163,81 +163,164 @@ export class ProxyWorker implements DurableObject {
163
163
  }
164
164
  }
165
165
 
166
- // explicitly NOT await-ing this promise, we are in a loop and want to process the whole queue quickly + synchronously
167
- void fetch(userWorkerUrl, new Request(request, { headers }))
168
- .then(async (res) => {
169
- res = new Response(res.body, res);
170
- rewriteUrlRelatedHeaders(res.headers, innerUrl, outerUrl);
171
-
172
- await checkForPreviewTokenError(res, this.env, proxyData);
173
-
174
- if (isHtmlResponse(res)) {
175
- res = insertLiveReloadScript(request, res, this.env, proxyData);
176
- }
177
-
178
- if (isSseResponse(res)) {
179
- void sendMessageToProxyController(this.env, {
180
- type: "sseResponseDetected",
181
- });
182
- }
183
-
184
- deferredResponse.resolve(res);
185
- })
186
- .catch((error: Error) => {
187
- // errors here are network errors or from response post-processing
188
- // to catch only network errors, use the 2nd param of the fetch.then()
189
-
190
- // we have crossed an async boundary, so proxyData may have changed
191
- // if proxyData.userWorkerUrl has changed, it means there is a new downstream UserWorker
192
- // and that this error is stale since it was for a request to the old UserWorker
193
- // only report the error if the request still targets the current
194
- // UserWorker. isSameUserWorkerOrigin compares origin (not href) so a
195
- // genuine error on a non-root path isn't misread as a reload — see
196
- // its docs.
197
- if (
198
- isSameUserWorkerOrigin(userWorkerUrl, this.proxyData?.userWorkerUrl)
199
- ) {
200
- void sendMessageToProxyController(this.env, {
201
- type: "error",
202
- error: {
203
- name: error.name,
204
- message: error.message,
205
- stack: error.stack,
206
- cause: error.cause,
207
- },
208
- });
209
-
210
- deferredResponse.reject(error);
211
- }
212
-
213
- // if the request can be retried (subset of idempotent requests which have no body), requeue it
214
- else if (request.method === "GET" || request.method === "HEAD") {
215
- this.requestRetryQueue.set(request, deferredResponse);
216
- // we would only end up here if the downstream UserWorker is chang*ing*
217
- // i.e. we are in a `pause`d state and expecting a `play` message soon
218
- // this request will be processed (retried) when the `play` message arrives
219
- // for that reason, we do not need to call `this.processQueue` here
220
- // (but, also, it can't hurt to call it since it bails when
221
- // in a `pause`d state i.e. `this.proxyData` is undefined)
222
- }
223
-
224
- // if the request cannot be retried, respond with 503 Service Unavailable
225
- // important to note, this is not an (unexpected) error -- it is an acceptable flow of local development
226
- // it would be incorrect to retry non-idempotent requests
227
- // and would require cloning all body streams to avoid stream reuse (which is inefficient but not out of the question in the future)
228
- // this is a good enough UX for now since it solves the most common GET use-case
229
- else {
230
- deferredResponse.resolve(
231
- new Response(
232
- "Your worker restarted mid-request. Please try sending the request again. Only GET or HEAD requests are retried automatically.",
233
- {
234
- status: 503,
235
- headers: { "Retry-After": "0" },
236
- }
166
+ /**
167
+ * Sends the request to the UserWorker and settles `deferredResponse`
168
+ * with the outcome — or requeues the request if the UserWorker is
169
+ * mid-reload. The promise chain is deliberately not awaited (`void`):
170
+ * we are in a loop and want to process the whole queue quickly +
171
+ * synchronously.
172
+ *
173
+ * A connection-level failure (the `fetch` itself rejects, so no
174
+ * response was received) on a same-origin GET/HEAD request is retried
175
+ * before being reported — see the rejection handler.
176
+ *
177
+ * Kept as a `const` arrow function: the handlers re-read
178
+ * `this.proxyData` across async boundaries to detect UserWorker
179
+ * reloads, so they need the ProxyWorker's lexical `this`.
180
+ *
181
+ * @param attempt the number of attempts that have already failed
182
+ * (`0` on the first try)
183
+ */
184
+ const attemptUserWorkerFetch = (attempt = 0) =>
185
+ void fetch(userWorkerUrl, new Request(request, { headers }))
186
+ .then(
187
+ async (res) => {
188
+ if (attempt > 0) {
189
+ console.warn(
190
+ `ProxyWorker: ${request.method} ${request.url} recovered on attempt ${attempt + 1} after a dropped connection to the UserWorker`
191
+ );
192
+ }
193
+
194
+ res = new Response(res.body, res);
195
+ rewriteUrlRelatedHeaders(res.headers, innerUrl, outerUrl);
196
+
197
+ await checkForPreviewTokenError(res, this.env, proxyData);
198
+
199
+ if (isHtmlResponse(res)) {
200
+ res = insertLiveReloadScript(request, res, this.env, proxyData);
201
+ }
202
+
203
+ if (isSseResponse(res)) {
204
+ void sendMessageToProxyController(this.env, {
205
+ type: "sseResponseDetected",
206
+ });
207
+ }
208
+
209
+ deferredResponse.resolve(res);
210
+ },
211
+ (error: Error) => {
212
+ // the fetch itself rejected: a connection-level failure, and no
213
+ // response was received. Errors thrown while post-processing a
214
+ // received response skip this handler and land in the .catch
215
+ // below, so they are reported rather than retried and can never
216
+ // re-run the UserWorker's handler.
217
+ //
218
+ // When the UserWorker origin is unchanged (i.e. this is not a
219
+ // reload — see the same check in the .catch below), the failure
220
+ // is most commonly the UserWorker's HTTP server closing a reused
221
+ // keep-alive connection at the same moment this request was
222
+ // written to it (kj's client pool idleTimeout and server
223
+ // pipelineTimeout both default to 5s, so a connection idling ~5s
224
+ // races the close). Retrying bodyless requests draws a fresh
225
+ // connection and absorbs the race, mirroring the requeue in the
226
+ // .catch for reloads: retry immediately, then once more after
227
+ // 250ms (3 attempts in total).
228
+ if (
229
+ isSameUserWorkerOrigin(
230
+ userWorkerUrl,
231
+ this.proxyData?.userWorkerUrl
232
+ ) &&
233
+ (request.method === "GET" || request.method === "HEAD") &&
234
+ attempt < 2
235
+ ) {
236
+ setTimeout(
237
+ () => {
238
+ // the UserWorker may have started reloading while this
239
+ // retry was queued (even at 0ms — setTimeout defers to a
240
+ // later task). `proxyData` carries the destination AND the
241
+ // headers, so retrying with the captured one could reach
242
+ // the pre-reload Worker or send a stale preview token.
243
+ // Requeue instead and let the current proxyData rebuild it.
244
+ if (this.proxyData !== proxyData) {
245
+ this.requestRetryQueue.set(request, deferredResponse);
246
+ this.processQueue();
247
+ return;
248
+ }
249
+
250
+ attemptUserWorkerFetch(attempt + 1);
251
+ },
252
+ attempt === 0 ? 0 : 250
253
+ );
254
+ return;
255
+ }
256
+
257
+ throw error;
258
+ }
259
+ )
260
+ .catch((error: Error) => {
261
+ // errors here are from response post-processing, or connection-
262
+ // level failures rethrown by the rejection handler above (a
263
+ // non-retriable method, or the retry budget was exhausted)
264
+
265
+ // we have crossed an async boundary, so proxyData may have changed
266
+ // if proxyData.userWorkerUrl has changed, it means there is a new downstream UserWorker
267
+ // and that this error is stale since it was for a request to the old UserWorker
268
+ // only report the error if the request still targets the current
269
+ // UserWorker. isSameUserWorkerOrigin compares origin (not href) so a
270
+ // genuine error on a non-root path isn't misread as a reload — see
271
+ // its docs.
272
+ if (
273
+ isSameUserWorkerOrigin(
274
+ userWorkerUrl,
275
+ this.proxyData?.userWorkerUrl
237
276
  )
238
- );
239
- }
240
- });
277
+ ) {
278
+ const attemptsNote = ` (failed after ${attempt + 1} ${
279
+ attempt === 0 ? "attempt" : "attempts"
280
+ })`;
281
+ void sendMessageToProxyController(this.env, {
282
+ type: "error",
283
+ error: {
284
+ name: error.name,
285
+ message: `${request.method} ${request.url}${attemptsNote}: ${error.message}`,
286
+ stack: error.stack,
287
+ cause: error.cause,
288
+ },
289
+ });
290
+
291
+ deferredResponse.reject(error);
292
+ }
293
+
294
+ // if the request can be retried (subset of idempotent requests which have no body), requeue it
295
+ else if (request.method === "GET" || request.method === "HEAD") {
296
+ this.requestRetryQueue.set(request, deferredResponse);
297
+ // we would only end up here if the downstream UserWorker is chang*ing*
298
+ // i.e. we are in a `pause`d state and expecting a `play` message soon
299
+ // this request will be processed (retried) when the `play` message arrives
300
+ // for that reason, we do not need to call `this.processQueue` here
301
+ // (but, also, it can't hurt to call it since it bails when
302
+ // in a `pause`d state i.e. `this.proxyData` is undefined)
303
+ }
304
+
305
+ // if the request cannot be retried, respond with 503 Service Unavailable
306
+ // important to note, this is not an (unexpected) error -- it is an acceptable flow of local development
307
+ // it would be incorrect to retry non-idempotent requests
308
+ // and would require cloning all body streams to avoid stream reuse (which is inefficient but not out of the question in the future)
309
+ // this is a good enough UX for now since it solves the most common GET use-case
310
+ else {
311
+ deferredResponse.resolve(
312
+ new Response(
313
+ "Your worker restarted mid-request. Please try sending the request again. Only GET or HEAD requests are retried automatically.",
314
+ {
315
+ status: 503,
316
+ headers: { "Retry-After": "0" },
317
+ }
318
+ )
319
+ );
320
+ }
321
+ });
322
+
323
+ attemptUserWorkerFetch();
241
324
  }
242
325
  }
243
326
  }
@@ -139,26 +139,57 @@ var ProxyWorker = class {
139
139
  headers.set(key, value);
140
140
  }
141
141
  }
142
- void fetch(userWorkerUrl, new Request(request, { headers })).then(async (res) => {
143
- res = new Response(res.body, res);
144
- rewriteUrlRelatedHeaders(res.headers, innerUrl, outerUrl);
145
- await checkForPreviewTokenError(res, this.env, proxyData);
146
- if (isHtmlResponse(res)) {
147
- res = insertLiveReloadScript(request, res, this.env, proxyData);
142
+ const attemptUserWorkerFetch = (attempt = 0) => void fetch(userWorkerUrl, new Request(request, { headers })).then(
143
+ async (res) => {
144
+ if (attempt > 0) {
145
+ console.warn(
146
+ `ProxyWorker: ${request.method} ${request.url} recovered on attempt ${attempt + 1} after a dropped connection to the UserWorker`
147
+ );
148
+ }
149
+ res = new Response(res.body, res);
150
+ rewriteUrlRelatedHeaders(res.headers, innerUrl, outerUrl);
151
+ await checkForPreviewTokenError(res, this.env, proxyData);
152
+ if (isHtmlResponse(res)) {
153
+ res = insertLiveReloadScript(request, res, this.env, proxyData);
154
+ }
155
+ if (isSseResponse(res)) {
156
+ void sendMessageToProxyController(this.env, {
157
+ type: "sseResponseDetected"
158
+ });
159
+ }
160
+ deferredResponse.resolve(res);
161
+ },
162
+ (error) => {
163
+ if (isSameUserWorkerOrigin(
164
+ userWorkerUrl,
165
+ this.proxyData?.userWorkerUrl
166
+ ) && (request.method === "GET" || request.method === "HEAD") && attempt < 2) {
167
+ setTimeout(
168
+ () => {
169
+ if (this.proxyData !== proxyData) {
170
+ this.requestRetryQueue.set(request, deferredResponse);
171
+ this.processQueue();
172
+ return;
173
+ }
174
+ attemptUserWorkerFetch(attempt + 1);
175
+ },
176
+ attempt === 0 ? 0 : 250
177
+ );
178
+ return;
179
+ }
180
+ throw error;
148
181
  }
149
- if (isSseResponse(res)) {
150
- void sendMessageToProxyController(this.env, {
151
- type: "sseResponseDetected"
152
- });
153
- }
154
- deferredResponse.resolve(res);
155
- }).catch((error) => {
156
- if (isSameUserWorkerOrigin(userWorkerUrl, this.proxyData?.userWorkerUrl)) {
182
+ ).catch((error) => {
183
+ if (isSameUserWorkerOrigin(
184
+ userWorkerUrl,
185
+ this.proxyData?.userWorkerUrl
186
+ )) {
187
+ const attemptsNote = ` (failed after ${attempt + 1} ${attempt === 0 ? "attempt" : "attempts"})`;
157
188
  void sendMessageToProxyController(this.env, {
158
189
  type: "error",
159
190
  error: {
160
191
  name: error.name,
161
- message: error.message,
192
+ message: `${request.method} ${request.url}${attemptsNote}: ${error.message}`,
162
193
  stack: error.stack,
163
194
  cause: error.cause
164
195
  }
@@ -178,6 +209,7 @@ var ProxyWorker = class {
178
209
  );
179
210
  }
180
211
  });
212
+ attemptUserWorkerFetch();
181
213
  }
182
214
  }
183
215
  };
@@ -1274,6 +1274,23 @@ type UnsafeBinding = {
1274
1274
  /**
1275
1275
  * Configuration for a container application
1276
1276
  */
1277
+ type ContainerObservability = {
1278
+ /** If observability is enabled for this container application */
1279
+ enabled?: boolean;
1280
+ logs?: {
1281
+ enabled?: boolean;
1282
+ };
1283
+ /**
1284
+ * Percentage of instances to target with application-level observability hot reloads.
1285
+ * Mutually exclusive with `target_instance_count`.
1286
+ */
1287
+ target_instance_percentage?: number;
1288
+ /**
1289
+ * Number of instances to target with application-level observability hot reloads.
1290
+ * Mutually exclusive with `target_instance_percentage`.
1291
+ */
1292
+ target_instance_count?: number;
1293
+ };
1277
1294
  type ContainerApp = {
1278
1295
  /**
1279
1296
  * Name of the application.
@@ -1320,6 +1337,12 @@ type ContainerApp = {
1320
1337
  * field. Exactly one of the two directions must be configured.
1321
1338
  */
1322
1339
  class_name?: string;
1340
+ /**
1341
+ * Specify the observability behavior of this container application.
1342
+ *
1343
+ * When set, this overrides the root `observability` config for this container.
1344
+ */
1345
+ observability?: ContainerObservability;
1323
1346
  /**
1324
1347
  * The scheduling policy of the application
1325
1348
  * @optional