wrangler 4.129.0 → 4.129.1

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wrangler",
3
- "version": "4.129.0",
3
+ "version": "4.129.1",
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",
69
+ "workerd": "1.20260907.1",
70
70
  "@cloudflare/kv-asset-handler": "0.5.0",
71
- "miniflare": "5.20260903.0-alpha",
72
- "@cloudflare/unenv-preset": "2.16.1"
71
+ "@cloudflare/unenv-preset": "2.16.1",
72
+ "miniflare": "5.20260907.0-alpha"
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.20260907.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/build-output-utils": "0.4.0",
159
160
  "@cloudflare/autoconfig": "0.4.2",
160
161
  "@cloudflare/cli-shared-helpers": "0.1.27",
161
- "@cloudflare/build-output-utils": "0.4.0",
162
162
  "@cloudflare/config": "0.10.0",
163
163
  "@cloudflare/containers-shared": "0.16.0",
164
- "@cloudflare/deploy-helpers": "0.10.1",
165
164
  "@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",
165
+ "@cloudflare/pages-shared": "^0.13.177",
166
+ "@cloudflare/remote-bindings": "0.0.20",
167
+ "@cloudflare/runtime-types": "0.0.22",
168
+ "@cloudflare/deploy-helpers": "0.10.2",
169
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",
170
+ "@cloudflare/workers-auth": "0.6.9",
173
171
  "@cloudflare/workers-shared": "0.19.9",
174
- "@cloudflare/workers-tsconfig": "0.0.0"
172
+ "@cloudflare/workers-utils": "0.36.0",
173
+ "@cloudflare/workers-tsconfig": "0.0.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.20260907.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
  };
@@ -26460,7 +26460,7 @@ var DEFAULT_COMPAT_DATE;
26460
26460
  var init_default_compat_date = __esm({
26461
26461
  "../workers-utils/src/default-compat-date.ts"() {
26462
26462
  init_import_meta_url();
26463
- DEFAULT_COMPAT_DATE = "2026-09-03";
26463
+ DEFAULT_COMPAT_DATE = "2026-09-07";
26464
26464
  }
26465
26465
  });
26466
26466
 
@@ -60702,7 +60702,7 @@ var name, version2;
60702
60702
  var init_package = __esm({
60703
60703
  "package.json"() {
60704
60704
  name = "wrangler";
60705
- version2 = "4.129.0";
60705
+ version2 = "4.129.1";
60706
60706
  }
60707
60707
  });
60708
60708
 
@@ -154282,18 +154282,18 @@ async function getSize(modules) {
154282
154282
  }
154283
154283
  function printBundleSize({ size, gzipSize }) {
154284
154284
  const bundleReport = `${(size / ONE_KIB_BYTES).toFixed(2)} KiB / gzip: ${(gzipSize / ONE_KIB_BYTES).toFixed(2)} KiB`;
154285
- const percentage = gzipSize / MAX_GZIP_SIZE_BYTES * 100;
154285
+ const percentage = size / MAX_UNCOMPRESSED_SIZE_BYTES * 100;
154286
154286
  const colorizedReport = percentage > 90 ? source_default.red(bundleReport) : percentage > 70 ? source_default.yellow(bundleReport) : source_default.green(bundleReport);
154287
154287
  logger.log(`Total Upload: ${colorizedReport}`);
154288
154288
  }
154289
- var ONE_KIB_BYTES, MAX_GZIP_SIZE_BYTES;
154289
+ var ONE_KIB_BYTES, MAX_UNCOMPRESSED_SIZE_BYTES;
154290
154290
  var init_bundle_reporter = __esm({
154291
154291
  "../deploy-helpers/src/deploy/helpers/bundle-reporter.ts"() {
154292
154292
  init_import_meta_url();
154293
154293
  init_source();
154294
154294
  init_context();
154295
154295
  ONE_KIB_BYTES = 1024;
154296
- MAX_GZIP_SIZE_BYTES = 3 * ONE_KIB_BYTES * ONE_KIB_BYTES;
154296
+ MAX_UNCOMPRESSED_SIZE_BYTES = 64 * ONE_KIB_BYTES * ONE_KIB_BYTES;
154297
154297
  __name(getSize, "getSize");
154298
154298
  __name(printBundleSize, "printBundleSize");
154299
154299
  }
@@ -163057,7 +163057,7 @@ function getPullRequestMetadata() {
163057
163057
  return getDirectPullRequestMetadata() ?? getGitHubPullRequestMetadata() ?? getGitLabPullRequestMetadata();
163058
163058
  }
163059
163059
  function resolveWorkerName(args, config2) {
163060
- const workerName = args.workerName ?? args["worker-name"] ?? config2.name;
163060
+ const workerName = getCIOverrideName() ?? args.workerName ?? args["worker-name"] ?? config2.name;
163061
163061
  if (!workerName) {
163062
163062
  throw new UserError(
163063
163063
  `Required Worker name missing. Please specify the Worker name in your ${configFileName(
@@ -165633,9 +165633,7 @@ var init_cf = __esm({
165633
165633
  "dns_records:edit",
165634
165634
  "dns_records:read",
165635
165635
  "dns_settings:read",
165636
- "email_routing:read",
165637
165636
  "email_routing:write",
165638
- "email_sending:read",
165639
165637
  "email_sending:write",
165640
165638
  "firstpartytags:write",
165641
165639
  "images:read",
@@ -169953,7 +169951,7 @@ var init_dist11 = __esm({
169953
169951
  init_wrapper();
169954
169952
  init_create_worker_upload_form();
169955
169953
  import_undici12 = __toESM(require_undici(), 1);
169956
- version3 = "0.0.19";
169954
+ version3 = "0.0.20";
169957
169955
  NoDefaultValueProvided2 = class extends UserError {
169958
169956
  static {
169959
169957
  __name(this, "NoDefaultValueProvided");
@@ -354740,6 +354738,12 @@ var init_DevEnv = __esm({
354740
354738
  logger2.debug(`Error in ${event.source}: ${event.reason}
354741
354739
  `, event.cause);
354742
354740
  logger2.debug("=> Error contextual data:", event.data);
354741
+ } else if (event.source === "ProxyController" && event.reason.startsWith("Error inside ProxyWorker")) {
354742
+ const detail = event.cause.message || event.cause.cause?.message || "unknown error";
354743
+ logger2.error(
354744
+ `${event.reason} (the affected request failed; the dev server continues): ${detail}`
354745
+ );
354746
+ logger2.debug("=> Error contextual data:", event.data);
354743
354747
  } else if (event.source === "ConfigController" && event.cause instanceof ParseError) {
354744
354748
  logger2.error(event.cause);
354745
354749
  this.emit("buildFailed", event);
@@ -361747,6 +361751,19 @@ init_esm2();
361747
361751
 
361748
361752
  // src/cli.ts
361749
361753
  init_api5();
361754
+
361755
+ // src/output-stream-errors.ts
361756
+ init_import_meta_url();
361757
+ function registerOutputStreamErrorHandler(stream2) {
361758
+ stream2.on("error", (error53) => {
361759
+ if (error53.code !== "EPIPE") {
361760
+ throw error53;
361761
+ }
361762
+ });
361763
+ }
361764
+ __name(registerOutputStreamErrorHandler, "registerOutputStreamErrorHandler");
361765
+
361766
+ // src/cli.ts
361750
361767
  init_src7();
361751
361768
  init_print_bindings2();
361752
361769
  init_client15();
@@ -361866,6 +361883,8 @@ init_src();
361866
361883
  init_src();
361867
361884
  init_experimental_commands_api();
361868
361885
  if (typeof vitest === "undefined" && __require.main === module) {
361886
+ registerOutputStreamErrorHandler(process12__default.default.stdout);
361887
+ registerOutputStreamErrorHandler(process12__default.default.stderr);
361869
361888
  main(hideBin(process12__default.default.argv)).catch((e10) => {
361870
361889
  const exitCode = e10 instanceof FatalError && e10.code || 1;
361871
361890
  process12__default.default.exit(exitCode);