@cloudflare/workers-utils 0.28.0 → 0.29.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.
@@ -1,4 +1,4 @@
1
- import { T as TailConsumer, aK as WorkerMetadata, R as RawConfig } from './config-BadLPAp8.mjs';
1
+ import { T as TailConsumer, aL as WorkerMetadata, R as RawConfig } from './config-BEcnaWpD.mjs';
2
2
  import { AssetConfig } from '@cloudflare/workers-shared';
3
3
  import { Cloudflare } from 'cloudflare';
4
4
  import 'node:url';
@@ -2382,10 +2382,20 @@ var APIError = class extends ParseError {
2382
2382
  * endpoint-specific structured error payloads.
2383
2383
  */
2384
2384
  meta;
2385
- constructor({ status, ...rest }) {
2385
+ /**
2386
+ * Optional number of milliseconds the API asked us to wait before retrying,
2387
+ * derived from the response's `Retry-After` header (if present).
2388
+ */
2389
+ retryAfterMs;
2390
+ constructor({
2391
+ status,
2392
+ retryAfterMs,
2393
+ ...rest
2394
+ }) {
2386
2395
  super(rest);
2387
2396
  this.name = this.constructor.name;
2388
2397
  this.#status = status;
2398
+ this.retryAfterMs = retryAfterMs;
2389
2399
  }
2390
2400
  get status() {
2391
2401
  return this.#status;
@@ -204,6 +204,21 @@ declare const getOpenNextDeployFromEnv: () => string | undefined;
204
204
  * `X_LOCAL_EXPLORER` enables the local explorer UI at /cdn-cgi/explorer.
205
205
  */
206
206
  declare const getLocalExplorerEnabledFromEnv: () => boolean;
207
+ /**
208
+ * `X_LOCAL_OBSERVABILITY` turns on local-dev observability capture. Both
209
+ * `wrangler dev` and the Vite plugin read it and pass it through as the one
210
+ * `unsafeObservability` Miniflare option, which makes core attach the trace
211
+ * collector to each user worker.
212
+ *
213
+ * Temporarily defaults to `false` for release: defaulting it on attaches extra
214
+ * per-worker services (collector + streaming tail) that destabilise the
215
+ * multi-process dev-registry scenario on Windows (workerd socket "fetch
216
+ * failed"). Capture is now opt-in — set `X_LOCAL_OBSERVABILITY=true`, or turn it
217
+ * on from the Local Explorer's Observability tab (Vite dev), which reloads the
218
+ * runtime with capture enabled. The explorer UI itself (`X_LOCAL_EXPLORER`)
219
+ * stays on by default so the tab is always available.
220
+ */
221
+ declare const getLocalObservabilityEnabledFromEnv: () => boolean;
207
222
  /**
208
223
  * `X_BROWSER_HEADFUL` opens the browser in headful (visible) mode when using the
209
224
  * Browser Run API in local development.
@@ -317,11 +332,22 @@ declare function performApiFetchBase(complianceConfig: ComplianceConfig, resourc
317
332
  declare function fetchInternalBase<ResponseType>(complianceConfig: ComplianceConfig, resource: string, init: RequestInit | undefined, userAgent: string, logger: Logger, queryParams?: URLSearchParams, abortSignal?: AbortSignal, credentials?: ApiCredentials): Promise<{
318
333
  response: ResponseType;
319
334
  status: number;
335
+ retryAfterMs?: number;
320
336
  }>;
321
337
  declare function fetchResultBase<ResponseType>(complianceConfig: ComplianceConfig, resource: string, init: RequestInit | undefined, userAgent: string, logger: Logger, queryParams?: URLSearchParams, abortSignal?: AbortSignal, credentials?: ApiCredentials): Promise<ResponseType>;
322
338
  declare function fetchListResultBase<ResponseType>(complianceConfig: ComplianceConfig, resource: string, init: RequestInit | undefined, userAgent: string, logger: Logger, queryParams?: URLSearchParams, credentials?: ApiCredentials): Promise<ResponseType[]>;
323
339
  declare function truncate(text: string, maxLength: number): string;
324
340
  declare function isWAFBlockResponse(headers: Headers): boolean;
341
+ /**
342
+ * Parses a `Retry-After` header value (https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After)
343
+ * into milliseconds to wait before retrying, or `undefined` if absent/unparsable.
344
+ *
345
+ * Per the HTTP spec, `Retry-After` may either be a number of delay-seconds,
346
+ * or an HTTP-date after which the request may be retried.
347
+ */
348
+ declare function parseRetryAfterValue(retryAfter: string | null | undefined): number | undefined;
349
+ /** Same as {@link parseRetryAfterValue}, reading the value from a `Headers` object. */
350
+ declare function parseRetryAfterMs(headers: Headers): number | undefined;
325
351
  declare function extractWAFBlockRayId(headers: Headers): string | undefined;
326
352
  declare function extractAccountTag(resource: string): string | undefined;
327
353
  interface PageResultInfo {
@@ -337,7 +363,7 @@ declare function renderError(err: FetchError | {
337
363
  documentation_url?: string;
338
364
  }, level?: number): string;
339
365
  declare function addAuthorizationHeader(headers: Headers, auth: ApiCredentials, overrideExisting?: boolean): void;
340
- declare function throwFetchError(resource: string, response: FetchResult<unknown>, status: number): never;
366
+ declare function throwFetchError(resource: string, response: FetchResult<unknown>, status: number, retryAfterMs?: number): never;
341
367
  /**
342
368
  * Fetch a raw KV value from the Cloudflare API.
343
369
  *
@@ -542,6 +568,11 @@ interface CfR2Bucket {
542
568
  jurisdiction?: string;
543
569
  remote?: boolean;
544
570
  raw?: boolean;
571
+ /** Settings that only apply to local development */
572
+ local_dev?: {
573
+ /** EXPERIMENTAL: credentials for the local S3-compatible endpoint */
574
+ experimental_s3_credentials?: LocalS3Credentials;
575
+ };
545
576
  }
546
577
  interface CfD1Database {
547
578
  binding: string;
@@ -1565,6 +1596,11 @@ type Entry = {
1565
1596
  interface Environment extends EnvironmentInheritable, EnvironmentNonInheritable {
1566
1597
  }
1567
1598
  type SimpleRoute = string;
1599
+ /** AWS SigV4 credentials for miniflare's local S3-compatible endpoint */
1600
+ interface LocalS3Credentials {
1601
+ accessKeyId: string;
1602
+ secretAccessKey: string;
1603
+ }
1568
1604
  type ZoneIdRoute = {
1569
1605
  pattern: string;
1570
1606
  zone_id: string;
@@ -2487,6 +2523,16 @@ interface EnvironmentNonInheritable {
2487
2523
  jurisdiction?: string;
2488
2524
  /** Whether the R2 bucket should be remote or not in local development */
2489
2525
  remote?: boolean;
2526
+ /** Settings that only apply to local development */
2527
+ local_dev?: {
2528
+ /**
2529
+ * EXPERIMENTAL: AWS SigV4 credentials for the local S3-compatible
2530
+ * endpoint. When set, the bucket is served at
2531
+ * `/cdn-cgi/local/r2/s3/<bucket-name>` during local development.
2532
+ * Ignored when the bucket runs remotely.
2533
+ */
2534
+ experimental_s3_credentials?: LocalS3Credentials;
2535
+ };
2490
2536
  }[];
2491
2537
  /**
2492
2538
  * Specifies D1 databases that are bound to this Worker environment.
@@ -3447,4 +3493,4 @@ interface EnvironmentMap {
3447
3493
  }
3448
3494
  declare const defaultWranglerConfig: Config;
3449
3495
 
3450
- export { type CfStreamBinding as $, type Assets as A, type Binding as B, type ComputedFields as C, type DurableObjectExport as D, type Exports as E, type ContainerEngine as F, type CfScriptFormat as G, type CfModuleType as H, type CfModule as I, type CfVars as J, type CfKvNamespace as K, type Logger as L, type CfSendEmailBindings as M, type CfWasmModuleBindings as N, type Observability as O, type PreviewsConfig as P, type CfTextBlobBindings as Q, type RawConfig as R, type StreamingTailConsumer as S, type TailConsumer as T, type UserLimits as U, type CfBrowserBinding as V, type WorkerEntrypointExport as W, type CfAIBinding as X, type CfImagesBinding as Y, type ZoneIdRoute as Z, type CfMediaBinding as _, type RedirectedRawConfig as a, type AsyncHook as a$, type CfVersionMetadataBinding as a0, type CfDataBlobBindings as a1, type CfDurableObject as a2, type CfWorkflow as a3, type CfQueue as a4, type CfR2Bucket as a5, type CfD1Database as a6, type CfVectorize as a7, type CfAISearchNamespace as a8, type CfAISearch as a9, type CfTailConsumer as aA, type CfUserLimits as aB, type CfWorkerInit as aC, type CfWorkerContext as aD, type CfWorkerSourceMap as aE, type Json as aF, type AssetConfigMetadata as aG, type AssetsOptions as aH, type ValidatedAssetsOptions as aI, type LegacyAssetPaths as aJ, type WorkerMetadata as aK, type ExportsReconciliationEntryBase as aL, type ExportsReconciliationInfo as aM, type ExportsReconciliationWarning as aN, type ExportsReconciliationErrorDetail as aO, type ExportsReconciliationRename as aP, type ExportsReconciliationTransfer as aQ, type ExportsReconciliationTransferPending as aR, type ExportsReconciliationResult as aS, type ServiceMetadataRes as aT, type ServiceFetch as aU, type File as aV, type BinaryFile as aW, type Trigger as aX, type CfAccount as aY, type HookValues as aZ, type Hook as a_, type CfWebSearch as aa, type CfAgentMemory as ab, type CfSecretsStoreSecrets as ac, type CfArtifacts as ad, type CfHelloWorld as ae, type CfFlagship as af, type CfWorkerLoader as ag, type CfRateLimit as ah, type CfHyperdrive as ai, type CfDevPluginCfg as aj, type CfService as ak, type CfVpcService as al, type CfVpcNetwork as am, type CfAnalyticsEngineDataset as an, type CfDispatchNamespace as ao, type CfMTlsCertificate as ap, type CfLogfwdr as aq, type CfLogfwdrBinding as ar, type CfAssetsBinding as as, type CfPipeline as at, type CfUnsafeBinding as au, type CfCapnp as av, type CfUnsafe as aw, type CfDurableObjectMigrations as ax, type CfExports as ay, type CfPlacement as az, type Config as b, fetchKVGetValueBase as b$, type LogLevel as b0, type NodeJSCompatMode as b1, type StartDevWorkerInput as b2, type Entry as b3, INHERIT_SYMBOL as b4, SERVICE_TAG_PREFIX as b5, ENVIRONMENT_TAG_PREFIX as b6, PATH_TO_DEPLOY_CONFIG as b7, JSON_CONFIG_FORMATS as b8, getC3CommandFromEnv as b9, getDisableConfigWatching as bA, getWranglerHideBanner as bB, getCloudflareEnv as bC, getOpenNextDeployFromEnv as bD, getLocalExplorerEnabledFromEnv as bE, getBrowserRenderingHeadfulFromEnv as bF, getCfFetchEnabledFromEnv as bG, getCfFetchPathFromEnv as bH, getWranglerCacheDirFromEnv as bI, getCloudflaredPathFromEnv as bJ, type ApiCredentials as bK, type FetchResult as bL, type FetchResultFetcher as bM, type FetchListResultFetcher as bN, type FetchPagedListResultFetcher as bO, performApiFetchBase as bP, fetchInternalBase as bQ, fetchResultBase as bR, fetchListResultBase as bS, truncate as bT, isWAFBlockResponse as bU, extractWAFBlockRayId as bV, extractAccountTag as bW, hasMorePages as bX, renderError as bY, addAuthorizationHeader as bZ, throwFetchError as b_, getWranglerSendMetricsFromEnv as ba, getWranglerSendErrorReportsFromEnv as bb, getCloudflareApiEnvironmentFromEnv as bc, type ComplianceConfig as bd, COMPLIANCE_REGION_CONFIG_PUBLIC as be, COMPLIANCE_REGION_CONFIG_UNKNOWN as bf, getCloudflareComplianceRegion as bg, getCloudflareApiBaseUrl as bh, getComplianceRegionSubdomain as bi, getSanitizeLogs as bj, getOutputFileDirectoryFromEnv as bk, getOutputFilePathFromEnv as bl, getCIMatchTag as bm, getCIOverrideName as bn, getCIOverrideNetworkModeHost as bo, getCIGeneratePreviewAlias as bp, getWorkersCIBranchName as bq, getBuildConditionsFromEnv as br, getBuildPlatformFromEnv as bs, getRegistryPath as bt, getD1ExtraLocationChoices as bu, getDockerPath as bv, getSubdomainMixedStateCheckDisabled as bw, getCloudflareLoadDevVarsFromDotEnv as bx, getCloudflareIncludeProcessEnvFromEnv as by, getTraceHeader as bz, type WorkerMetadataBinding as c, type FetchKVGetValueFetcher as c0, hasCursor as c1, maybeAddTraceHeader as c2, type Route as d, type RawDevConfig as e, type ConfigFields as f, type RawEnvironment as g, defaultWranglerConfig as h, LOGGER_LEVELS as i, type LoggerLevel as j, type Environment as k, type ZoneNameRoute as l, type CustomDomainRoute as m, type CloudchamberConfig as n, type ContainerApp as o, type DurableObjectMigration as p, type DurableObjectExportStorage as q, type ConfiguredExport as r, type DurableObjectBindings as s, type WorkflowBinding as t, type EnvironmentNonInheritable as u, type Rule as v, type ConfigModuleRuleType as w, type DispatchNamespaceOutbound as x, type CacheOptions as y, type DockerConfiguration as z };
3496
+ export { type CfMediaBinding as $, type Assets as A, type Binding as B, type ComputedFields as C, type DurableObjectExport as D, type Exports as E, type DockerConfiguration as F, type ContainerEngine as G, type CfScriptFormat as H, type CfModuleType as I, type CfModule as J, type CfVars as K, type Logger as L, type CfKvNamespace as M, type CfSendEmailBindings as N, type Observability as O, type PreviewsConfig as P, type CfWasmModuleBindings as Q, type RawConfig as R, type StreamingTailConsumer as S, type TailConsumer as T, type UserLimits as U, type CfTextBlobBindings as V, type WorkerEntrypointExport as W, type CfBrowserBinding as X, type CfAIBinding as Y, type ZoneIdRoute as Z, type CfImagesBinding as _, type RedirectedRawConfig as a, type Hook as a$, type CfStreamBinding as a0, type CfVersionMetadataBinding as a1, type CfDataBlobBindings as a2, type CfDurableObject as a3, type CfWorkflow as a4, type CfQueue as a5, type CfR2Bucket as a6, type CfD1Database as a7, type CfVectorize as a8, type CfAISearchNamespace as a9, type CfPlacement as aA, type CfTailConsumer as aB, type CfUserLimits as aC, type CfWorkerInit as aD, type CfWorkerContext as aE, type CfWorkerSourceMap as aF, type Json as aG, type AssetConfigMetadata as aH, type AssetsOptions as aI, type ValidatedAssetsOptions as aJ, type LegacyAssetPaths as aK, type WorkerMetadata as aL, type ExportsReconciliationEntryBase as aM, type ExportsReconciliationInfo as aN, type ExportsReconciliationWarning as aO, type ExportsReconciliationErrorDetail as aP, type ExportsReconciliationRename as aQ, type ExportsReconciliationTransfer as aR, type ExportsReconciliationTransferPending as aS, type ExportsReconciliationResult as aT, type ServiceMetadataRes as aU, type ServiceFetch as aV, type File as aW, type BinaryFile as aX, type Trigger as aY, type CfAccount as aZ, type HookValues as a_, type CfAISearch as aa, type CfWebSearch as ab, type CfAgentMemory as ac, type CfSecretsStoreSecrets as ad, type CfArtifacts as ae, type CfHelloWorld as af, type CfFlagship as ag, type CfWorkerLoader as ah, type CfRateLimit as ai, type CfHyperdrive as aj, type CfDevPluginCfg as ak, type CfService as al, type CfVpcService as am, type CfVpcNetwork as an, type CfAnalyticsEngineDataset as ao, type CfDispatchNamespace as ap, type CfMTlsCertificate as aq, type CfLogfwdr as ar, type CfLogfwdrBinding as as, type CfAssetsBinding as at, type CfPipeline as au, type CfUnsafeBinding as av, type CfCapnp as aw, type CfUnsafe as ax, type CfDurableObjectMigrations as ay, type CfExports as az, type Config as b, hasMorePages as b$, type AsyncHook as b0, type LogLevel as b1, type NodeJSCompatMode as b2, type StartDevWorkerInput as b3, type Entry as b4, INHERIT_SYMBOL as b5, SERVICE_TAG_PREFIX as b6, ENVIRONMENT_TAG_PREFIX as b7, PATH_TO_DEPLOY_CONFIG as b8, JSON_CONFIG_FORMATS as b9, getTraceHeader as bA, getDisableConfigWatching as bB, getWranglerHideBanner as bC, getCloudflareEnv as bD, getOpenNextDeployFromEnv as bE, getLocalExplorerEnabledFromEnv as bF, getLocalObservabilityEnabledFromEnv as bG, getBrowserRenderingHeadfulFromEnv as bH, getCfFetchEnabledFromEnv as bI, getCfFetchPathFromEnv as bJ, getWranglerCacheDirFromEnv as bK, getCloudflaredPathFromEnv as bL, type ApiCredentials as bM, type FetchResult as bN, type FetchResultFetcher as bO, type FetchListResultFetcher as bP, type FetchPagedListResultFetcher as bQ, performApiFetchBase as bR, fetchInternalBase as bS, fetchResultBase as bT, fetchListResultBase as bU, truncate as bV, isWAFBlockResponse as bW, parseRetryAfterValue as bX, parseRetryAfterMs as bY, extractWAFBlockRayId as bZ, extractAccountTag as b_, getC3CommandFromEnv as ba, getWranglerSendMetricsFromEnv as bb, getWranglerSendErrorReportsFromEnv as bc, getCloudflareApiEnvironmentFromEnv as bd, type ComplianceConfig as be, COMPLIANCE_REGION_CONFIG_PUBLIC as bf, COMPLIANCE_REGION_CONFIG_UNKNOWN as bg, getCloudflareComplianceRegion as bh, getCloudflareApiBaseUrl as bi, getComplianceRegionSubdomain as bj, getSanitizeLogs as bk, getOutputFileDirectoryFromEnv as bl, getOutputFilePathFromEnv as bm, getCIMatchTag as bn, getCIOverrideName as bo, getCIOverrideNetworkModeHost as bp, getCIGeneratePreviewAlias as bq, getWorkersCIBranchName as br, getBuildConditionsFromEnv as bs, getBuildPlatformFromEnv as bt, getRegistryPath as bu, getD1ExtraLocationChoices as bv, getDockerPath as bw, getSubdomainMixedStateCheckDisabled as bx, getCloudflareLoadDevVarsFromDotEnv as by, getCloudflareIncludeProcessEnvFromEnv as bz, type WorkerMetadataBinding as c, renderError as c0, addAuthorizationHeader as c1, throwFetchError as c2, fetchKVGetValueBase as c3, type FetchKVGetValueFetcher as c4, hasCursor as c5, maybeAddTraceHeader as c6, type Route as d, type RawDevConfig as e, type ConfigFields as f, type RawEnvironment as g, defaultWranglerConfig as h, LOGGER_LEVELS as i, type LoggerLevel as j, type Environment as k, type LocalS3Credentials as l, type ZoneNameRoute as m, type CustomDomainRoute as n, type CloudchamberConfig as o, type ContainerApp as p, type DurableObjectMigration as q, type DurableObjectExportStorage as r, type ConfiguredExport as s, type DurableObjectBindings as t, type WorkflowBinding as u, type EnvironmentNonInheritable as v, type Rule as w, type ConfigModuleRuleType as x, type DispatchNamespaceOutbound as y, type CacheOptions as z };
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { C as ComputedFields, B as Binding, R as RawConfig, b as Config, E as Exports, D as DurableObjectExport, W as WorkerEntrypointExport, c as WorkerMetadataBinding, L as Logger, d as Route } from './config-BadLPAp8.mjs';
2
- export { bK as ApiCredentials, aG as AssetConfigMetadata, A as Assets, aH as AssetsOptions, a$ as AsyncHook, aW as BinaryFile, be as COMPLIANCE_REGION_CONFIG_PUBLIC, bf as COMPLIANCE_REGION_CONFIG_UNKNOWN, y as CacheOptions, X as CfAIBinding, a9 as CfAISearch, a8 as CfAISearchNamespace, aY as CfAccount, ab as CfAgentMemory, an as CfAnalyticsEngineDataset, ad as CfArtifacts, as as CfAssetsBinding, V as CfBrowserBinding, av as CfCapnp, a6 as CfD1Database, a1 as CfDataBlobBindings, aj as CfDevPluginCfg, ao as CfDispatchNamespace, a2 as CfDurableObject, ax as CfDurableObjectMigrations, ay as CfExports, af as CfFlagship, ae as CfHelloWorld, ai as CfHyperdrive, Y as CfImagesBinding, K as CfKvNamespace, aq as CfLogfwdr, ar as CfLogfwdrBinding, ap as CfMTlsCertificate, _ as CfMediaBinding, I as CfModule, H as CfModuleType, at as CfPipeline, az as CfPlacement, a4 as CfQueue, a5 as CfR2Bucket, ah as CfRateLimit, G as CfScriptFormat, ac as CfSecretsStoreSecrets, M as CfSendEmailBindings, ak as CfService, $ as CfStreamBinding, aA as CfTailConsumer, Q as CfTextBlobBindings, aw as CfUnsafe, au as CfUnsafeBinding, aB as CfUserLimits, J as CfVars, a7 as CfVectorize, a0 as CfVersionMetadataBinding, am as CfVpcNetwork, al as CfVpcService, N as CfWasmModuleBindings, aa as CfWebSearch, aD as CfWorkerContext, aC as CfWorkerInit, ag as CfWorkerLoader, aE as CfWorkerSourceMap, a3 as CfWorkflow, n as CloudchamberConfig, bd as ComplianceConfig, f as ConfigFields, w as ConfigModuleRuleType, r as ConfiguredExport, o as ContainerApp, F as ContainerEngine, m as CustomDomainRoute, x as DispatchNamespaceOutbound, z as DockerConfiguration, s as DurableObjectBindings, q as DurableObjectExportStorage, p as DurableObjectMigration, b6 as ENVIRONMENT_TAG_PREFIX, b3 as Entry, k as Environment, u as EnvironmentNonInheritable, aL as ExportsReconciliationEntryBase, aO as ExportsReconciliationErrorDetail, aM as ExportsReconciliationInfo, aP as ExportsReconciliationRename, aS as ExportsReconciliationResult, aQ as ExportsReconciliationTransfer, aR as ExportsReconciliationTransferPending, aN as ExportsReconciliationWarning, c0 as FetchKVGetValueFetcher, bN as FetchListResultFetcher, bO as FetchPagedListResultFetcher, bL as FetchResult, bM as FetchResultFetcher, aV as File, a_ as Hook, aZ as HookValues, b4 as INHERIT_SYMBOL, b8 as JSON_CONFIG_FORMATS, aF as Json, i as LOGGER_LEVELS, aJ as LegacyAssetPaths, b0 as LogLevel, j as LoggerLevel, b1 as NodeJSCompatMode, O as Observability, b7 as PATH_TO_DEPLOY_CONFIG, P as PreviewsConfig, e as RawDevConfig, g as RawEnvironment, a as RedirectedRawConfig, v as Rule, b5 as SERVICE_TAG_PREFIX, aU as ServiceFetch, aT as ServiceMetadataRes, b2 as StartDevWorkerInput, S as StreamingTailConsumer, T as TailConsumer, aX as Trigger, U as UserLimits, aI as ValidatedAssetsOptions, aK as WorkerMetadata, t as WorkflowBinding, Z as ZoneIdRoute, l as ZoneNameRoute, bZ as addAuthorizationHeader, h as defaultWranglerConfig, bW as extractAccountTag, bV as extractWAFBlockRayId, bQ as fetchInternalBase, b$ as fetchKVGetValueBase, bS as fetchListResultBase, bR as fetchResultBase, bF as getBrowserRenderingHeadfulFromEnv, br as getBuildConditionsFromEnv, bs as getBuildPlatformFromEnv, b9 as getC3CommandFromEnv, bp as getCIGeneratePreviewAlias, bm as getCIMatchTag, bn as getCIOverrideName, bo as getCIOverrideNetworkModeHost, bG as getCfFetchEnabledFromEnv, bH as getCfFetchPathFromEnv, bh as getCloudflareApiBaseUrl, bc as getCloudflareApiEnvironmentFromEnv, bg as getCloudflareComplianceRegion, bC as getCloudflareEnv, by as getCloudflareIncludeProcessEnvFromEnv, bx as getCloudflareLoadDevVarsFromDotEnv, bJ as getCloudflaredPathFromEnv, bi as getComplianceRegionSubdomain, bu as getD1ExtraLocationChoices, bA as getDisableConfigWatching, bv as getDockerPath, bE as getLocalExplorerEnabledFromEnv, bD as getOpenNextDeployFromEnv, bk as getOutputFileDirectoryFromEnv, bl as getOutputFilePathFromEnv, bt as getRegistryPath, bj as getSanitizeLogs, bw as getSubdomainMixedStateCheckDisabled, bz as getTraceHeader, bq as getWorkersCIBranchName, bI as getWranglerCacheDirFromEnv, bB as getWranglerHideBanner, bb as getWranglerSendErrorReportsFromEnv, ba as getWranglerSendMetricsFromEnv, c1 as hasCursor, bX as hasMorePages, bU as isWAFBlockResponse, c2 as maybeAddTraceHeader, bP as performApiFetchBase, bY as renderError, b_ as throwFetchError, bT as truncate } from './config-BadLPAp8.mjs';
1
+ import { C as ComputedFields, B as Binding, R as RawConfig, b as Config, E as Exports, D as DurableObjectExport, W as WorkerEntrypointExport, c as WorkerMetadataBinding, L as Logger, d as Route } from './config-BEcnaWpD.mjs';
2
+ export { bM as ApiCredentials, aH as AssetConfigMetadata, A as Assets, aI as AssetsOptions, b0 as AsyncHook, aX as BinaryFile, bf as COMPLIANCE_REGION_CONFIG_PUBLIC, bg as COMPLIANCE_REGION_CONFIG_UNKNOWN, z as CacheOptions, Y as CfAIBinding, aa as CfAISearch, a9 as CfAISearchNamespace, aZ as CfAccount, ac as CfAgentMemory, ao as CfAnalyticsEngineDataset, ae as CfArtifacts, at as CfAssetsBinding, X as CfBrowserBinding, aw as CfCapnp, a7 as CfD1Database, a2 as CfDataBlobBindings, ak as CfDevPluginCfg, ap as CfDispatchNamespace, a3 as CfDurableObject, ay as CfDurableObjectMigrations, az as CfExports, ag as CfFlagship, af as CfHelloWorld, aj as CfHyperdrive, _ as CfImagesBinding, M as CfKvNamespace, ar as CfLogfwdr, as as CfLogfwdrBinding, aq as CfMTlsCertificate, $ as CfMediaBinding, J as CfModule, I as CfModuleType, au as CfPipeline, aA as CfPlacement, a5 as CfQueue, a6 as CfR2Bucket, ai as CfRateLimit, H as CfScriptFormat, ad as CfSecretsStoreSecrets, N as CfSendEmailBindings, al as CfService, a0 as CfStreamBinding, aB as CfTailConsumer, V as CfTextBlobBindings, ax as CfUnsafe, av as CfUnsafeBinding, aC as CfUserLimits, K as CfVars, a8 as CfVectorize, a1 as CfVersionMetadataBinding, an as CfVpcNetwork, am as CfVpcService, Q as CfWasmModuleBindings, ab as CfWebSearch, aE as CfWorkerContext, aD as CfWorkerInit, ah as CfWorkerLoader, aF as CfWorkerSourceMap, a4 as CfWorkflow, o as CloudchamberConfig, be as ComplianceConfig, f as ConfigFields, x as ConfigModuleRuleType, s as ConfiguredExport, p as ContainerApp, G as ContainerEngine, n as CustomDomainRoute, y as DispatchNamespaceOutbound, F as DockerConfiguration, t as DurableObjectBindings, r as DurableObjectExportStorage, q as DurableObjectMigration, b7 as ENVIRONMENT_TAG_PREFIX, b4 as Entry, k as Environment, v as EnvironmentNonInheritable, aM as ExportsReconciliationEntryBase, aP as ExportsReconciliationErrorDetail, aN as ExportsReconciliationInfo, aQ as ExportsReconciliationRename, aT as ExportsReconciliationResult, aR as ExportsReconciliationTransfer, aS as ExportsReconciliationTransferPending, aO as ExportsReconciliationWarning, c4 as FetchKVGetValueFetcher, bP as FetchListResultFetcher, bQ as FetchPagedListResultFetcher, bN as FetchResult, bO as FetchResultFetcher, aW as File, a$ as Hook, a_ as HookValues, b5 as INHERIT_SYMBOL, b9 as JSON_CONFIG_FORMATS, aG as Json, i as LOGGER_LEVELS, aK as LegacyAssetPaths, l as LocalS3Credentials, b1 as LogLevel, j as LoggerLevel, b2 as NodeJSCompatMode, O as Observability, b8 as PATH_TO_DEPLOY_CONFIG, P as PreviewsConfig, e as RawDevConfig, g as RawEnvironment, a as RedirectedRawConfig, w as Rule, b6 as SERVICE_TAG_PREFIX, aV as ServiceFetch, aU as ServiceMetadataRes, b3 as StartDevWorkerInput, S as StreamingTailConsumer, T as TailConsumer, aY as Trigger, U as UserLimits, aJ as ValidatedAssetsOptions, aL as WorkerMetadata, u as WorkflowBinding, Z as ZoneIdRoute, m as ZoneNameRoute, c1 as addAuthorizationHeader, h as defaultWranglerConfig, b_ as extractAccountTag, bZ as extractWAFBlockRayId, bS as fetchInternalBase, c3 as fetchKVGetValueBase, bU as fetchListResultBase, bT as fetchResultBase, bH as getBrowserRenderingHeadfulFromEnv, bs as getBuildConditionsFromEnv, bt as getBuildPlatformFromEnv, ba as getC3CommandFromEnv, bq as getCIGeneratePreviewAlias, bn as getCIMatchTag, bo as getCIOverrideName, bp as getCIOverrideNetworkModeHost, bI as getCfFetchEnabledFromEnv, bJ as getCfFetchPathFromEnv, bi as getCloudflareApiBaseUrl, bd as getCloudflareApiEnvironmentFromEnv, bh as getCloudflareComplianceRegion, bD as getCloudflareEnv, bz as getCloudflareIncludeProcessEnvFromEnv, by as getCloudflareLoadDevVarsFromDotEnv, bL as getCloudflaredPathFromEnv, bj as getComplianceRegionSubdomain, bv as getD1ExtraLocationChoices, bB as getDisableConfigWatching, bw as getDockerPath, bF as getLocalExplorerEnabledFromEnv, bG as getLocalObservabilityEnabledFromEnv, bE as getOpenNextDeployFromEnv, bl as getOutputFileDirectoryFromEnv, bm as getOutputFilePathFromEnv, bu as getRegistryPath, bk as getSanitizeLogs, bx as getSubdomainMixedStateCheckDisabled, bA as getTraceHeader, br as getWorkersCIBranchName, bK as getWranglerCacheDirFromEnv, bC as getWranglerHideBanner, bc as getWranglerSendErrorReportsFromEnv, bb as getWranglerSendMetricsFromEnv, c5 as hasCursor, b$ as hasMorePages, bW as isWAFBlockResponse, c6 as maybeAddTraceHeader, bY as parseRetryAfterMs, bX as parseRetryAfterValue, bR as performApiFetchBase, c0 as renderError, c2 as throwFetchError, bV as truncate } from './config-BEcnaWpD.mjs';
3
3
  import * as jsoncParser from 'jsonc-parser';
4
4
  export { constructWranglerConfig } from './browser.mjs';
5
5
  export { GetGlobalConfigPathOptions, getGlobalConfigPath, getGlobalWranglerCachePath } from './global-wrangler-config-path.mjs';
@@ -283,8 +283,14 @@ declare class APIError extends ParseError {
283
283
  meta?: {
284
284
  details?: unknown;
285
285
  } & Record<string, unknown>;
286
- constructor({ status, ...rest }: MessageInit & {
286
+ /**
287
+ * Optional number of milliseconds the API asked us to wait before retrying,
288
+ * derived from the response's `Retry-After` header (if present).
289
+ */
290
+ retryAfterMs?: number;
291
+ constructor({ status, retryAfterMs, ...rest }: MessageInit & {
287
292
  status?: number;
293
+ retryAfterMs?: number;
288
294
  });
289
295
  get status(): number | undefined;
290
296
  isGatewayError(): boolean;
@@ -560,6 +566,8 @@ type VariableNames =
560
566
  | "CLOUDFLARE_AUTH_USE_KEYRING"
561
567
  /** Enable the local explorer UI at /cdn-cgi/explorer (experimental, default: false). */
562
568
  | "X_LOCAL_EXPLORER"
569
+ /** Enable local-dev observability capture (experimental, default: false). */
570
+ | "X_LOCAL_OBSERVABILITY"
563
571
  /** Open the browser in headful (visible) mode when using the Browser Run API in local dev (default: false). */
564
572
  | "X_BROWSER_HEADFUL"
565
573
  /** Override command used by `wrangler init` (default: "create cloudflare"). */
package/dist/index.mjs CHANGED
@@ -2,8 +2,8 @@ export { assertNever, constructWranglerConfig, getTodaysCompatDate, isCompatDate
2
2
  import { getGlobalConfigPath } from './chunk-34VZWBGB.mjs';
3
3
  export { getGlobalConfigPath, getGlobalWranglerCachePath } from './chunk-34VZWBGB.mjs';
4
4
  export { MetricsRegistry } from './chunk-Z62CVNHJ.mjs';
5
- import { partitionExports, UserError, dedent, isRedirectedRawConfig, configFileName, formatConfigSnippet, FatalError, parsePackageJSON, readFileSync, ParseError, parseJSON, APIError, dir, parseTOML, modify, applyEdits, format, dist_default, parseJSONC } from './chunk-Y3JVLYM6.mjs';
6
- export { APIError, CommandLineArgsError, DeprecationError, ENVIRONMENT_TAG_PREFIX, FatalError, INHERIT_SYMBOL, JSON_CONFIG_FORMATS, JsonFriendlyFatalError, MissingConfigError, PATH_TO_DEPLOY_CONFIG, ParseError, SERVICE_TAG_PREFIX, UserError, configFileName, configFormat, createFatalError, experimental_readRawConfig, findWranglerConfig, formatConfigSnippet, indexLocation, isRedirectedConfig, parseByteSize, parseHumanDuration, parseJSON, parseJSONC, parseNonHyphenedUuid, parsePackageJSON, parseTOML, partitionExports, readFileSync, readFileSyncToBuffer, resolveWranglerConfigPath, searchLocation } from './chunk-Y3JVLYM6.mjs';
5
+ import { partitionExports, UserError, isRedirectedRawConfig, dedent, configFileName, formatConfigSnippet, FatalError, parsePackageJSON, readFileSync, ParseError, parseJSON, APIError, dir, parseTOML, modify, applyEdits, format, dist_default, parseJSONC } from './chunk-3K53PSCY.mjs';
6
+ export { APIError, CommandLineArgsError, DeprecationError, ENVIRONMENT_TAG_PREFIX, FatalError, INHERIT_SYMBOL, JSON_CONFIG_FORMATS, JsonFriendlyFatalError, MissingConfigError, PATH_TO_DEPLOY_CONFIG, ParseError, SERVICE_TAG_PREFIX, UserError, configFileName, configFormat, createFatalError, experimental_readRawConfig, findWranglerConfig, formatConfigSnippet, indexLocation, isRedirectedConfig, parseByteSize, parseHumanDuration, parseJSON, parseJSONC, parseNonHyphenedUuid, parsePackageJSON, parseTOML, partitionExports, readFileSync, readFileSyncToBuffer, resolveWranglerConfigPath, searchLocation } from './chunk-3K53PSCY.mjs';
7
7
  import { isDirectory, removeDirSync } from './chunk-53IMCORZ.mjs';
8
8
  export { isDirectory, removeDir, removeDirSync } from './chunk-53IMCORZ.mjs';
9
9
  import { __commonJS, __name, __require, __export, __toESM } from './chunk-Q72B4Q5Z.mjs';
@@ -16992,6 +16992,10 @@ var getLocalExplorerEnabledFromEnv = getBooleanEnvironmentVariableFactory({
16992
16992
  variableName: "X_LOCAL_EXPLORER",
16993
16993
  defaultValue: true
16994
16994
  });
16995
+ var getLocalObservabilityEnabledFromEnv = getBooleanEnvironmentVariableFactory({
16996
+ variableName: "X_LOCAL_OBSERVABILITY",
16997
+ defaultValue: false
16998
+ });
16995
16999
  var getBrowserRenderingHeadfulFromEnv = getBooleanEnvironmentVariableFactory({
16996
17000
  variableName: "X_BROWSER_HEADFUL",
16997
17001
  defaultValue: false
@@ -17520,14 +17524,21 @@ function normalizeAndValidateConfig(rawConfig, configPath, userConfigPath, args,
17520
17524
  const diagnostics = new Diagnostics(
17521
17525
  `Processing ${configPath ? path2__default.relative(process.cwd(), configPath) : "wrangler"} configuration:`
17522
17526
  );
17527
+ const isRedirectedConfig2 = isRedirectedRawConfig(
17528
+ rawConfig,
17529
+ configPath,
17530
+ userConfigPath
17531
+ );
17523
17532
  if ("legacy_env" in rawConfig) {
17524
- diagnostics.errors.push(
17525
- dedent`
17526
- The "legacy_env" field is no longer supported, so please remove it from your configuration file.
17527
- Service environments have been removed, and each environment is now deployed as its own Worker named "<name>-<environment>". This matches the behaviour of "legacy_env = true", which was the default, so removing the field will not change how your Worker is deployed.
17528
- Refer to https://developers.cloudflare.com/workers/wrangler/environments/ for more information.
17529
- `
17530
- );
17533
+ if (!isRedirectedConfig2) {
17534
+ diagnostics.errors.push(
17535
+ dedent`
17536
+ The "legacy_env" field is no longer supported, so please remove it from your configuration file.
17537
+ Service environments have been removed, and each environment is now deployed as its own Worker named "<name>-<environment>". This matches the behaviour of "legacy_env = true", which was the default, so removing the field will not change how your Worker is deployed.
17538
+ Refer to https://developers.cloudflare.com/workers/wrangler/environments/ for more information.
17539
+ `
17540
+ );
17541
+ }
17531
17542
  delete rawConfig.legacy_env;
17532
17543
  }
17533
17544
  validateOptionalProperty(
@@ -17603,11 +17614,6 @@ function normalizeAndValidateConfig(rawConfig, configPath, userConfigPath, args,
17603
17614
  isDispatchNamespace,
17604
17615
  preserveOriginalMain
17605
17616
  );
17606
- const isRedirectedConfig2 = isRedirectedRawConfig(
17607
- rawConfig,
17608
- configPath,
17609
- userConfigPath
17610
- );
17611
17617
  const definedEnvironments = Object.keys(rawConfig.env ?? {});
17612
17618
  if (isRedirectedConfig2 && definedEnvironments.length > 0) {
17613
17619
  diagnostics.errors.push(
@@ -20592,12 +20598,47 @@ var validateR2Binding = /* @__PURE__ */ __name((diagnostics, field, value) => {
20592
20598
  if (!isRemoteValid(value, field, diagnostics)) {
20593
20599
  isValid = false;
20594
20600
  }
20601
+ if (hasProperty(value, "local_dev")) {
20602
+ const localDev = value.local_dev;
20603
+ if (typeof localDev !== "object" || localDev === null) {
20604
+ diagnostics.errors.push(
20605
+ `"${field}" bindings should, optionally, have an object "local_dev" field but got ${JSON.stringify(
20606
+ value
20607
+ )}.`
20608
+ );
20609
+ isValid = false;
20610
+ } else {
20611
+ experimental(
20612
+ diagnostics,
20613
+ { local_dev: localDev },
20614
+ "local_dev.experimental_s3_credentials"
20615
+ );
20616
+ if (hasProperty(localDev, "experimental_s3_credentials")) {
20617
+ const credentials = localDev.experimental_s3_credentials;
20618
+ if (typeof credentials !== "object" || credentials === null || !isRequiredProperty(credentials, "accessKeyId", "string") || !isRequiredProperty(credentials, "secretAccessKey", "string")) {
20619
+ diagnostics.errors.push(
20620
+ `"${field}" bindings should, optionally, have a "local_dev.experimental_s3_credentials" field with string "accessKeyId" and "secretAccessKey" fields, but got ${JSON.stringify(
20621
+ value
20622
+ )}.`
20623
+ );
20624
+ isValid = false;
20625
+ }
20626
+ }
20627
+ validateAdditionalProperties(
20628
+ diagnostics,
20629
+ `${field}.local_dev`,
20630
+ Object.keys(localDev),
20631
+ ["experimental_s3_credentials"]
20632
+ );
20633
+ }
20634
+ }
20595
20635
  validateAdditionalProperties(diagnostics, field, Object.keys(value), [
20596
20636
  "binding",
20597
20637
  "bucket_name",
20598
20638
  "preview_bucket_name",
20599
20639
  "jurisdiction",
20600
- "remote"
20640
+ "remote",
20641
+ "local_dev"
20601
20642
  ]);
20602
20643
  return isValid;
20603
20644
  }, "validateR2Binding");
@@ -24052,6 +24093,7 @@ async function fetchInternalBase(complianceConfig, resource, init = {}, userAgen
24052
24093
  logHeaders(response.headers, logger);
24053
24094
  logger.debugWithSanitization?.("RESPONSE:", jsonText);
24054
24095
  logger.debug("-- END CF API RESPONSE");
24096
+ const retryAfterMs = parseRetryAfterMs(response.headers);
24055
24097
  if (!jsonText && (response.status === 204 || response.status === 205)) {
24056
24098
  return {
24057
24099
  response: {
@@ -24060,7 +24102,8 @@ async function fetchInternalBase(complianceConfig, resource, init = {}, userAgen
24060
24102
  errors: [],
24061
24103
  messages: []
24062
24104
  },
24063
- status: response.status
24105
+ status: response.status,
24106
+ retryAfterMs
24064
24107
  };
24065
24108
  }
24066
24109
  if (isWAFBlockResponse(response.headers)) {
@@ -24069,12 +24112,13 @@ async function fetchInternalBase(complianceConfig, resource, init = {}, userAgen
24069
24112
  method,
24070
24113
  resource,
24071
24114
  response.status,
24072
- response.statusText
24115
+ response.statusText,
24116
+ retryAfterMs
24073
24117
  );
24074
24118
  }
24075
24119
  try {
24076
24120
  const json2 = parseJSON(jsonText);
24077
- return { response: json2, status: response.status };
24121
+ return { response: json2, status: response.status, retryAfterMs };
24078
24122
  } catch {
24079
24123
  const rayId = extractWAFBlockRayId(response.headers);
24080
24124
  throw new APIError({
@@ -24089,13 +24133,18 @@ async function fetchInternalBase(complianceConfig, resource, init = {}, userAgen
24089
24133
  ...rayId ? [{ text: `Cloudflare Ray ID: ${rayId}` }] : []
24090
24134
  ],
24091
24135
  status: response.status,
24136
+ retryAfterMs,
24092
24137
  telemetryMessage: false
24093
24138
  });
24094
24139
  }
24095
24140
  }
24096
24141
  __name(fetchInternalBase, "fetchInternalBase");
24097
24142
  async function fetchResultBase(complianceConfig, resource, init = {}, userAgent, logger, queryParams, abortSignal, credentials) {
24098
- const { response: json2, status } = await fetchInternalBase(
24143
+ const {
24144
+ response: json2,
24145
+ status,
24146
+ retryAfterMs
24147
+ } = await fetchInternalBase(
24099
24148
  complianceConfig,
24100
24149
  resource,
24101
24150
  init,
@@ -24108,7 +24157,7 @@ async function fetchResultBase(complianceConfig, resource, init = {}, userAgent,
24108
24157
  if (json2.success) {
24109
24158
  return json2.result;
24110
24159
  } else {
24111
- throwFetchError(resource, json2, status);
24160
+ throwFetchError(resource, json2, status, retryAfterMs);
24112
24161
  }
24113
24162
  }
24114
24163
  __name(fetchResultBase, "fetchResultBase");
@@ -24121,7 +24170,11 @@ async function fetchListResultBase(complianceConfig, resource, init = {}, userAg
24121
24170
  queryParams = new URLSearchParams(queryParams);
24122
24171
  queryParams.set("cursor", cursor);
24123
24172
  }
24124
- const { response: json2, status } = await fetchInternalBase(
24173
+ const {
24174
+ response: json2,
24175
+ status,
24176
+ retryAfterMs
24177
+ } = await fetchInternalBase(
24125
24178
  complianceConfig,
24126
24179
  resource,
24127
24180
  init,
@@ -24139,7 +24192,7 @@ async function fetchListResultBase(complianceConfig, resource, init = {}, userAg
24139
24192
  getMoreResults = false;
24140
24193
  }
24141
24194
  } else {
24142
- throwFetchError(resource, json2, status);
24195
+ throwFetchError(resource, json2, status, retryAfterMs);
24143
24196
  }
24144
24197
  }
24145
24198
  return results;
@@ -24157,6 +24210,24 @@ function isWAFBlockResponse(headers) {
24157
24210
  return headers.get("cf-mitigated") === "challenge";
24158
24211
  }
24159
24212
  __name(isWAFBlockResponse, "isWAFBlockResponse");
24213
+ function parseRetryAfterValue(retryAfter) {
24214
+ if (!retryAfter) {
24215
+ return void 0;
24216
+ }
24217
+ if (/^\d+$/.test(retryAfter.trim())) {
24218
+ return Number(retryAfter) * 1e3;
24219
+ }
24220
+ const retryAfterDate = new Date(retryAfter);
24221
+ if (!Number.isNaN(retryAfterDate.getTime())) {
24222
+ return Math.max(0, retryAfterDate.getTime() - Date.now());
24223
+ }
24224
+ return void 0;
24225
+ }
24226
+ __name(parseRetryAfterValue, "parseRetryAfterValue");
24227
+ function parseRetryAfterMs(headers) {
24228
+ return parseRetryAfterValue(headers.get("Retry-After"));
24229
+ }
24230
+ __name(parseRetryAfterMs, "parseRetryAfterMs");
24160
24231
  function extractWAFBlockRayId(headers) {
24161
24232
  return headers.get("cf-ray") ?? void 0;
24162
24233
  }
@@ -24236,7 +24307,7 @@ function escapeCharacter(character) {
24236
24307
  }).join("");
24237
24308
  }
24238
24309
  __name(escapeCharacter, "escapeCharacter");
24239
- function throwFetchError(resource, response, status) {
24310
+ function throwFetchError(resource, response, status, retryAfterMs) {
24240
24311
  const errors = response.errors ?? [];
24241
24312
  for (const error52 of errors) {
24242
24313
  maybeThrowFriendlyError(error52);
@@ -24254,10 +24325,19 @@ function throwFetchError(resource, response, status) {
24254
24325
  notes.push({ text: fallbackMessage });
24255
24326
  }
24256
24327
  }
24328
+ if (retryAfterMs !== void 0) {
24329
+ notes.push({
24330
+ text: `The API responded with a "Retry-After" header indicating you should wait ${Math.ceil(retryAfterMs / 1e3)} second(s) before retrying.`
24331
+ });
24332
+ }
24257
24333
  const error51 = new APIError({
24258
24334
  text: `A request to the Cloudflare API (${resource}) failed.`,
24259
24335
  notes,
24260
24336
  status,
24337
+ // hoist the parsed `Retry-After` header (if any) so consumers such as
24338
+ // `retryOnAPIFailure()` can back off for the amount of time the API
24339
+ // asked us to wait, e.g. when rate limited (HTTP 429).
24340
+ retryAfterMs,
24261
24341
  telemetryMessage: false
24262
24342
  });
24263
24343
  const code = errors[0]?.code;
@@ -24272,7 +24352,7 @@ function throwFetchError(resource, response, status) {
24272
24352
  throw error51;
24273
24353
  }
24274
24354
  __name(throwFetchError, "throwFetchError");
24275
- function throwWAFBlockError(headers, method, resource, status, statusText) {
24355
+ function throwWAFBlockError(headers, method, resource, status, statusText, retryAfterMs) {
24276
24356
  const rayId = extractWAFBlockRayId(headers);
24277
24357
  throw new APIError({
24278
24358
  text: "The Cloudflare API responded with a WAF block page instead of the expected JSON response",
@@ -24289,6 +24369,7 @@ function throwWAFBlockError(headers, method, resource, status, statusText) {
24289
24369
  }
24290
24370
  ],
24291
24371
  status,
24372
+ retryAfterMs,
24292
24373
  telemetryMessage: false
24293
24374
  });
24294
24375
  }
@@ -24401,23 +24482,41 @@ ${url2}`
24401
24482
  }
24402
24483
  __name(handleBrowserOpenError, "handleBrowserOpenError");
24403
24484
  var MAX_ATTEMPTS = 3;
24485
+ var MAX_RETRY_AFTER_MS = 6e4;
24404
24486
  async function retryOnAPIFailure(action, logger, backoff = 0, attempts = MAX_ATTEMPTS, abortSignal) {
24405
24487
  try {
24406
24488
  return await action();
24407
24489
  } catch (err) {
24408
24490
  if (err instanceof APIError) {
24409
- if (!err.isRetryable()) {
24491
+ if (!err.isRetryable() && err.status !== 429) {
24410
24492
  throw err;
24411
24493
  }
24412
24494
  } else if (err instanceof DOMException && err.name === "TimeoutError") ; else if (!(err instanceof TypeError)) {
24413
24495
  throw err;
24414
24496
  }
24415
- logger.debug(`Retrying API call after error...`);
24416
- logger.debug(err);
24497
+ const retryAfterMs = err instanceof APIError ? err.retryAfterMs : void 0;
24498
+ if (retryAfterMs !== void 0 && retryAfterMs > MAX_RETRY_AFTER_MS) {
24499
+ throw err;
24500
+ }
24417
24501
  if (attempts <= 1) {
24418
24502
  throw err;
24419
24503
  }
24420
- await setTimeout$1(backoff, void 0, { signal: abortSignal });
24504
+ const jitter = Math.random() * 1e3;
24505
+ let wait = backoff;
24506
+ if (retryAfterMs !== void 0) {
24507
+ wait = retryAfterMs + jitter;
24508
+ } else if (err instanceof APIError && err.status === 429) {
24509
+ wait = Math.max(backoff, 1e3) + jitter;
24510
+ }
24511
+ if (retryAfterMs !== void 0) {
24512
+ logger.info(
24513
+ `Received a "Retry-After" header from the Cloudflare API. Waiting ${Math.ceil(retryAfterMs / 1e3)} second(s) before retrying...`
24514
+ );
24515
+ } else {
24516
+ logger.debug(`Retrying API call after error...`);
24517
+ logger.debug(err);
24518
+ }
24519
+ await setTimeout$1(wait, void 0, { signal: abortSignal });
24421
24520
  return retryOnAPIFailure(
24422
24521
  action,
24423
24522
  logger,
@@ -24601,4 +24700,4 @@ safe-buffer/index.js:
24601
24700
  (*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> *)
24602
24701
  */
24603
24702
 
24604
- export { BunPackageManager, COMPLIANCE_REGION_CONFIG_PUBLIC, COMPLIANCE_REGION_CONFIG_UNKNOWN, Diagnostics, LOGGER_LEVELS, NpmPackageManager, NubPackageManager, PatchConfigError, PnpmPackageManager, YarnPackageManager, addAuthorizationHeader, bucketFormatMessage, checkWorkerNameValidity, createConfigCache, defaultWranglerConfig, experimental_patchConfig, extractAccountTag, extractWAFBlockRayId, fetchInternalBase, fetchKVGetValueBase, fetchLatestNpmVersion, fetchListResultBase, fetchResultBase, formatTime, friendlyBindingNames2 as friendlyBindingNames, getBindingLocalSupport, getBindingTypeFriendlyName, getBooleanEnvironmentVariableFactory, getBrowserRenderingHeadfulFromEnv, getBuildConditionsFromEnv, getBuildPlatformFromEnv, getC3CommandFromEnv, getCIGeneratePreviewAlias, getCIMatchTag, getCIOverrideName, getCIOverrideNetworkModeHost, getCfFetchEnabledFromEnv, getCfFetchPathFromEnv, getCloudflareApiBaseUrl, getCloudflareApiEnvironmentFromEnv, getCloudflareComplianceRegion, getCloudflareEnv, getCloudflareIncludeProcessEnvFromEnv, getCloudflareLoadDevVarsFromDotEnv, getCloudflaredPathFromEnv, getComplianceRegionSubdomain, getD1ExtraLocationChoices, getDisableConfigWatching, getDockerPath, getDurableObjectExports, getEnvironmentVariableFactory, getHostFromRoute, getHostFromUrl, getInstalledPackageVersion, getLocalExplorerEnabledFromEnv, getOpenNextDeployFromEnv, getOutputFileDirectoryFromEnv, getOutputFilePathFromEnv, getPackagePath, getRegistryPath, getSanitizeLogs, getSubdomainMixedStateCheckDisabled, getTraceHeader, getWorkerName, getWorkerNameFromProject, getWorkersCIBranchName, getWranglerCacheDirFromEnv, getWranglerHiddenDirPath, getWranglerHideBanner, getWranglerSendErrorReportsFromEnv, getWranglerSendMetricsFromEnv, getWranglerTmpDir, getZoneFromRoute, hasCursor, hasDurableObjectExports, hasMorePages, hasProperty, isCI, isDockerfile, isInteractive, isNonInteractiveOrCI, isOptionalProperty, isPackageInstalled, isPagesConfig, isRequiredProperty, isValidR2BucketName, isWAFBlockResponse, maybeAddTraceHeader, normalizeAndValidateConfig, openInBrowser, performApiFetchBase, renderError, retryOnAPIFailure, spawnCloudflared, startTunnel, sweepStaleWranglerTmpDirs, throwFetchError, toValidWorkerName, truncate, validatePagesConfig };
24703
+ export { BunPackageManager, COMPLIANCE_REGION_CONFIG_PUBLIC, COMPLIANCE_REGION_CONFIG_UNKNOWN, Diagnostics, LOGGER_LEVELS, NpmPackageManager, NubPackageManager, PatchConfigError, PnpmPackageManager, YarnPackageManager, addAuthorizationHeader, bucketFormatMessage, checkWorkerNameValidity, createConfigCache, defaultWranglerConfig, experimental_patchConfig, extractAccountTag, extractWAFBlockRayId, fetchInternalBase, fetchKVGetValueBase, fetchLatestNpmVersion, fetchListResultBase, fetchResultBase, formatTime, friendlyBindingNames2 as friendlyBindingNames, getBindingLocalSupport, getBindingTypeFriendlyName, getBooleanEnvironmentVariableFactory, getBrowserRenderingHeadfulFromEnv, getBuildConditionsFromEnv, getBuildPlatformFromEnv, getC3CommandFromEnv, getCIGeneratePreviewAlias, getCIMatchTag, getCIOverrideName, getCIOverrideNetworkModeHost, getCfFetchEnabledFromEnv, getCfFetchPathFromEnv, getCloudflareApiBaseUrl, getCloudflareApiEnvironmentFromEnv, getCloudflareComplianceRegion, getCloudflareEnv, getCloudflareIncludeProcessEnvFromEnv, getCloudflareLoadDevVarsFromDotEnv, getCloudflaredPathFromEnv, getComplianceRegionSubdomain, getD1ExtraLocationChoices, getDisableConfigWatching, getDockerPath, getDurableObjectExports, getEnvironmentVariableFactory, getHostFromRoute, getHostFromUrl, getInstalledPackageVersion, getLocalExplorerEnabledFromEnv, getLocalObservabilityEnabledFromEnv, getOpenNextDeployFromEnv, getOutputFileDirectoryFromEnv, getOutputFilePathFromEnv, getPackagePath, getRegistryPath, getSanitizeLogs, getSubdomainMixedStateCheckDisabled, getTraceHeader, getWorkerName, getWorkerNameFromProject, getWorkersCIBranchName, getWranglerCacheDirFromEnv, getWranglerHiddenDirPath, getWranglerHideBanner, getWranglerSendErrorReportsFromEnv, getWranglerSendMetricsFromEnv, getWranglerTmpDir, getZoneFromRoute, hasCursor, hasDurableObjectExports, hasMorePages, hasProperty, isCI, isDockerfile, isInteractive, isNonInteractiveOrCI, isOptionalProperty, isPackageInstalled, isPagesConfig, isRequiredProperty, isValidR2BucketName, isWAFBlockResponse, maybeAddTraceHeader, normalizeAndValidateConfig, openInBrowser, parseRetryAfterMs, parseRetryAfterValue, performApiFetchBase, renderError, retryOnAPIFailure, spawnCloudflared, startTunnel, sweepStaleWranglerTmpDirs, throwFetchError, toValidWorkerName, truncate, validatePagesConfig };