wrangler 4.71.0 → 4.72.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.
- package/package.json +7 -7
- package/wrangler-dist/cli.d.ts +1 -3
- package/wrangler-dist/cli.js +157 -141
- package/wrangler-dist/metafile-cjs.json +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wrangler",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.72.0",
|
|
4
4
|
"description": "Command-line interface for all things Cloudflare Workers",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"wrangler",
|
|
@@ -54,16 +54,16 @@
|
|
|
54
54
|
"esbuild": "0.27.3",
|
|
55
55
|
"path-to-regexp": "6.3.0",
|
|
56
56
|
"unenv": "2.0.0-rc.24",
|
|
57
|
-
"workerd": "1.
|
|
57
|
+
"workerd": "1.20260310.1",
|
|
58
58
|
"@cloudflare/kv-asset-handler": "0.4.2",
|
|
59
59
|
"@cloudflare/unenv-preset": "2.15.0",
|
|
60
|
-
"miniflare": "4.
|
|
60
|
+
"miniflare": "4.20260310.0"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@aws-sdk/client-s3": "^3.721.0",
|
|
64
64
|
"@bomb.sh/tab": "^0.0.12",
|
|
65
65
|
"@cloudflare/types": "6.18.4",
|
|
66
|
-
"@cloudflare/workers-types": "^4.
|
|
66
|
+
"@cloudflare/workers-types": "^4.20260310.1",
|
|
67
67
|
"@cspotcode/source-map-support": "0.8.1",
|
|
68
68
|
"@netlify/build-info": "^10.2.0",
|
|
69
69
|
"@sentry/node": "^7.86.0",
|
|
@@ -119,7 +119,7 @@
|
|
|
119
119
|
"minimatch": "^5.1.0",
|
|
120
120
|
"mock-socket": "^9.3.1",
|
|
121
121
|
"msw": "2.12.0",
|
|
122
|
-
"node-forge": "^1.3.
|
|
122
|
+
"node-forge": "^1.3.2",
|
|
123
123
|
"open": "^8.4.0",
|
|
124
124
|
"p-queue": "^9.0.0",
|
|
125
125
|
"patch-console": "^1.0.0",
|
|
@@ -150,14 +150,14 @@
|
|
|
150
150
|
"@cloudflare/cli": "1.2.1",
|
|
151
151
|
"@cloudflare/containers-shared": "0.10.0",
|
|
152
152
|
"@cloudflare/eslint-config-shared": "1.2.1",
|
|
153
|
-
"@cloudflare/pages-shared": "^0.13.
|
|
153
|
+
"@cloudflare/pages-shared": "^0.13.113",
|
|
154
154
|
"@cloudflare/workers-shared": "0.19.1",
|
|
155
155
|
"@cloudflare/workers-tsconfig": "0.0.0",
|
|
156
156
|
"@cloudflare/workers-utils": "0.12.0",
|
|
157
157
|
"@cloudflare/workflows-shared": "0.6.0"
|
|
158
158
|
},
|
|
159
159
|
"peerDependencies": {
|
|
160
|
-
"@cloudflare/workers-types": "^4.
|
|
160
|
+
"@cloudflare/workers-types": "^4.20260310.1"
|
|
161
161
|
},
|
|
162
162
|
"peerDependenciesMeta": {
|
|
163
163
|
"@cloudflare/workers-types": {
|
package/wrangler-dist/cli.d.ts
CHANGED
|
@@ -688,9 +688,7 @@ interface StartDevWorkerInput {
|
|
|
688
688
|
};
|
|
689
689
|
unsafe?: Omit<CfUnsafe, "bindings">;
|
|
690
690
|
assets?: string;
|
|
691
|
-
experimental?:
|
|
692
|
-
tailLogs: boolean;
|
|
693
|
-
};
|
|
691
|
+
experimental?: Record<string, never>;
|
|
694
692
|
}
|
|
695
693
|
type StartDevWorkerOptions = Omit<StartDevWorkerInput, "assets" | "containers"> & {
|
|
696
694
|
/** A worker's directory. Usually where the Wrangler configuration file is located */
|
package/wrangler-dist/cli.js
CHANGED
|
@@ -38325,7 +38325,7 @@ async function prepareContainerImagesForDev(args) {
|
|
|
38325
38325
|
await checkExposedPorts(dockerPath, options);
|
|
38326
38326
|
}
|
|
38327
38327
|
}
|
|
38328
|
-
if (!aborted
|
|
38328
|
+
if (!aborted) {
|
|
38329
38329
|
await pullEgressInterceptorImage(dockerPath);
|
|
38330
38330
|
}
|
|
38331
38331
|
}
|
|
@@ -38370,7 +38370,7 @@ var init_images = __esm({
|
|
|
38370
38370
|
init_login();
|
|
38371
38371
|
init_registry2();
|
|
38372
38372
|
init_utils();
|
|
38373
|
-
DEFAULT_CONTAINER_EGRESS_INTERCEPTOR_IMAGE = "cloudflare/proxy-everything:
|
|
38373
|
+
DEFAULT_CONTAINER_EGRESS_INTERCEPTOR_IMAGE = "cloudflare/proxy-everything:3f5e832@sha256:816255f5b6ebdc2cdcddb578d803121e7ee9cfe178442da07725d75a66cdcf37";
|
|
38374
38374
|
__name(getEgressInterceptorImage, "getEgressInterceptorImage");
|
|
38375
38375
|
__name(pullEgressInterceptorImage, "pullEgressInterceptorImage");
|
|
38376
38376
|
__name(pullImage, "pullImage");
|
|
@@ -43179,6 +43179,10 @@ function flipObject(obj) {
|
|
|
43179
43179
|
Object.entries(obj).filter(([_5, v8]) => !!v8).map(([k7, v8]) => [v8, k7])
|
|
43180
43180
|
);
|
|
43181
43181
|
}
|
|
43182
|
+
function stripQueryString(modulePath) {
|
|
43183
|
+
const queryIndex = modulePath.indexOf("?");
|
|
43184
|
+
return queryIndex !== -1 ? modulePath.slice(0, queryIndex) : modulePath;
|
|
43185
|
+
}
|
|
43182
43186
|
function createModuleCollector(props) {
|
|
43183
43187
|
const parsedRules = parseRules(props.rules);
|
|
43184
43188
|
const modules = [];
|
|
@@ -43246,16 +43250,17 @@ function createModuleCollector(props) {
|
|
|
43246
43250
|
args.importer
|
|
43247
43251
|
)}". This will stop working in the future. Replace references to "${args.path}" with "./${args.path}";`
|
|
43248
43252
|
);
|
|
43253
|
+
const cleanedPath = stripQueryString(args.path);
|
|
43249
43254
|
const filePath = path3__namespace.default.join(
|
|
43250
43255
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
43251
43256
|
props.wrangler1xLegacyModuleReferences.rootDirectory,
|
|
43252
|
-
|
|
43257
|
+
cleanedPath
|
|
43253
43258
|
);
|
|
43254
43259
|
const fileContent = await fs12.readFile(
|
|
43255
43260
|
filePath
|
|
43256
43261
|
);
|
|
43257
43262
|
const fileHash = crypto2__default.default.createHash("sha1").update(fileContent).digest("hex");
|
|
43258
|
-
const fileName = props.preserveFileNames ?
|
|
43263
|
+
const fileName = props.preserveFileNames ? cleanedPath : `./${fileHash}-${path3__namespace.default.basename(cleanedPath)}`;
|
|
43259
43264
|
const { rule } = rulesMatchers.find(({ regex: regex2 }) => regex2.test(fileName)) || {};
|
|
43260
43265
|
if (rule) {
|
|
43261
43266
|
modules.push({
|
|
@@ -43289,15 +43294,16 @@ function createModuleCollector(props) {
|
|
|
43289
43294
|
if (args.pluginData?.skip) {
|
|
43290
43295
|
return;
|
|
43291
43296
|
}
|
|
43292
|
-
|
|
43297
|
+
const cleanedPath = stripQueryString(args.path);
|
|
43298
|
+
let filePath = path3__namespace.default.join(args.resolveDir, cleanedPath);
|
|
43293
43299
|
if (foundModulePaths.includes(filePath)) {
|
|
43294
|
-
return { path:
|
|
43300
|
+
return { path: cleanedPath, external: true };
|
|
43295
43301
|
}
|
|
43296
43302
|
if (isJavaScriptModuleRule(rule)) {
|
|
43297
43303
|
return;
|
|
43298
43304
|
}
|
|
43299
43305
|
try {
|
|
43300
|
-
const resolved = await build5.resolve(
|
|
43306
|
+
const resolved = await build5.resolve(cleanedPath, {
|
|
43301
43307
|
kind: args.kind,
|
|
43302
43308
|
importer: args.importer,
|
|
43303
43309
|
resolveDir: args.resolveDir,
|
|
@@ -43311,7 +43317,7 @@ function createModuleCollector(props) {
|
|
|
43311
43317
|
} catch {
|
|
43312
43318
|
}
|
|
43313
43319
|
try {
|
|
43314
|
-
const resolved = (0, import_resolve.sync)(
|
|
43320
|
+
const resolved = (0, import_resolve.sync)(cleanedPath, {
|
|
43315
43321
|
basedir: args.resolveDir
|
|
43316
43322
|
});
|
|
43317
43323
|
filePath = resolved;
|
|
@@ -43321,7 +43327,7 @@ function createModuleCollector(props) {
|
|
|
43321
43327
|
filePath
|
|
43322
43328
|
);
|
|
43323
43329
|
const fileHash = crypto2__default.default.createHash("sha1").update(fileContent).digest("hex");
|
|
43324
|
-
const fileName = props.preserveFileNames ?
|
|
43330
|
+
const fileName = props.preserveFileNames ? cleanedPath : `./${fileHash}-${path3__namespace.default.basename(cleanedPath)}`;
|
|
43325
43331
|
modules.push({
|
|
43326
43332
|
name: fileName,
|
|
43327
43333
|
filePath,
|
|
@@ -43409,6 +43415,7 @@ var init_module_collection = __esm({
|
|
|
43409
43415
|
PythonRequirement: "python-requirement"
|
|
43410
43416
|
};
|
|
43411
43417
|
ModuleTypeToRuleType = flipObject(RuleTypeToModuleType);
|
|
43418
|
+
__name(stripQueryString, "stripQueryString");
|
|
43412
43419
|
modulesWatchRegexp = /^wrangler:modules-watch$/;
|
|
43413
43420
|
modulesWatchNamespace = "wrangler-modules-watch";
|
|
43414
43421
|
noopModuleCollector = {
|
|
@@ -51084,7 +51091,7 @@ var name, version;
|
|
|
51084
51091
|
var init_package = __esm({
|
|
51085
51092
|
"package.json"() {
|
|
51086
51093
|
name = "wrangler";
|
|
51087
|
-
version = "4.
|
|
51094
|
+
version = "4.72.0";
|
|
51088
51095
|
}
|
|
51089
51096
|
});
|
|
51090
51097
|
|
|
@@ -170042,9 +170049,6 @@ async function executeLocally({
|
|
|
170042
170049
|
if (Array.isArray(value)) {
|
|
170043
170050
|
value = `[${value.join(", ")}]`;
|
|
170044
170051
|
}
|
|
170045
|
-
if (value === null) {
|
|
170046
|
-
value = "null";
|
|
170047
|
-
}
|
|
170048
170052
|
return [key, value];
|
|
170049
170053
|
})
|
|
170050
170054
|
)
|
|
@@ -229613,7 +229617,6 @@ ${JSON.stringify(defaultRoutesJSONSpec, null, 2)}`
|
|
|
229613
229617
|
siteInclude: void 0,
|
|
229614
229618
|
siteExclude: void 0,
|
|
229615
229619
|
enableContainers: false,
|
|
229616
|
-
experimentalTailLogs: true,
|
|
229617
229620
|
types: false
|
|
229618
229621
|
})
|
|
229619
229622
|
);
|
|
@@ -273064,11 +273067,15 @@ var init_tail2 = __esm({
|
|
|
273064
273067
|
});
|
|
273065
273068
|
|
|
273066
273069
|
// src/routes.ts
|
|
273067
|
-
async function getWorkersDevSubdomain(complianceConfig, accountId, configPath) {
|
|
273070
|
+
async function getWorkersDevSubdomain(complianceConfig, accountId, configPath, apiToken) {
|
|
273068
273071
|
try {
|
|
273069
273072
|
const { subdomain } = await fetchResult(
|
|
273070
273073
|
complianceConfig,
|
|
273071
|
-
`/accounts/${accountId}/workers/subdomain
|
|
273074
|
+
`/accounts/${accountId}/workers/subdomain`,
|
|
273075
|
+
void 0,
|
|
273076
|
+
void 0,
|
|
273077
|
+
void 0,
|
|
273078
|
+
apiToken
|
|
273072
273079
|
);
|
|
273073
273080
|
return `${subdomain}${getComplianceRegionSubdomain(complianceConfig)}.workers.dev`;
|
|
273074
273081
|
} catch (e9) {
|
|
@@ -275989,6 +275996,21 @@ function collectCoreBindingsPerEnvironment(args) {
|
|
|
275989
275996
|
}
|
|
275990
275997
|
__name(collectEnvironmentBindings, "collectEnvironmentBindings");
|
|
275991
275998
|
const { rawConfig } = exports.experimental_readRawConfig(args);
|
|
275999
|
+
const topLevelInheritableBindings = [];
|
|
276000
|
+
for (const inheritableDef of INHERITABLE_BINDINGS) {
|
|
276001
|
+
const bindingName = inheritableDef.getBindingName(rawConfig);
|
|
276002
|
+
if (!bindingName) {
|
|
276003
|
+
continue;
|
|
276004
|
+
}
|
|
276005
|
+
topLevelInheritableBindings.push({
|
|
276006
|
+
binding: {
|
|
276007
|
+
bindingCategory: inheritableDef.bindingCategory,
|
|
276008
|
+
name: bindingName,
|
|
276009
|
+
type: inheritableDef.type
|
|
276010
|
+
},
|
|
276011
|
+
definition: inheritableDef
|
|
276012
|
+
});
|
|
276013
|
+
}
|
|
275992
276014
|
const topLevelBindings = collectEnvironmentBindings(
|
|
275993
276015
|
rawConfig,
|
|
275994
276016
|
TOP_LEVEL_ENV_NAME
|
|
@@ -275998,6 +276020,18 @@ function collectCoreBindingsPerEnvironment(args) {
|
|
|
275998
276020
|
}
|
|
275999
276021
|
for (const [envName, env6] of Object.entries(rawConfig.env ?? {})) {
|
|
276000
276022
|
const envBindings = collectEnvironmentBindings(env6, envName);
|
|
276023
|
+
for (const inheritable3 of topLevelInheritableBindings) {
|
|
276024
|
+
const alreadyHasBinding = envBindings.some(
|
|
276025
|
+
(b11) => b11.bindingCategory === inheritable3.binding.bindingCategory
|
|
276026
|
+
);
|
|
276027
|
+
if (alreadyHasBinding) {
|
|
276028
|
+
continue;
|
|
276029
|
+
}
|
|
276030
|
+
if (inheritable3.definition.hasProperty(env6)) {
|
|
276031
|
+
continue;
|
|
276032
|
+
}
|
|
276033
|
+
envBindings.push(inheritable3.binding);
|
|
276034
|
+
}
|
|
276001
276035
|
if (envBindings.length > 0) {
|
|
276002
276036
|
result.set(envName, envBindings);
|
|
276003
276037
|
}
|
|
@@ -276225,7 +276259,7 @@ function collectPipelinesPerEnvironment(args) {
|
|
|
276225
276259
|
}
|
|
276226
276260
|
return result;
|
|
276227
276261
|
}
|
|
276228
|
-
var typesCommand, validateTypesFile, logHorizontalRule;
|
|
276262
|
+
var typesCommand, validateTypesFile, logHorizontalRule, INHERITABLE_BINDINGS;
|
|
276229
276263
|
var init_type_generation = __esm({
|
|
276230
276264
|
"src/type-generation/index.ts"() {
|
|
276231
276265
|
init_import_meta_url();
|
|
@@ -276494,6 +276528,14 @@ ${content.join("\n")}`,
|
|
|
276494
276528
|
const screenWidth = process.stdout.columns;
|
|
276495
276529
|
logger.log(source_default.dim("\u2500".repeat(Math.min(screenWidth, 60))));
|
|
276496
276530
|
}, "logHorizontalRule");
|
|
276531
|
+
INHERITABLE_BINDINGS = [
|
|
276532
|
+
{
|
|
276533
|
+
bindingCategory: "assets",
|
|
276534
|
+
getBindingName: /* @__PURE__ */ __name((env6) => env6?.assets?.binding, "getBindingName"),
|
|
276535
|
+
hasProperty: /* @__PURE__ */ __name((env6) => env6?.assets !== void 0, "hasProperty"),
|
|
276536
|
+
type: "Fetcher"
|
|
276537
|
+
}
|
|
276538
|
+
];
|
|
276497
276539
|
__name(collectVarsPerEnvironment, "collectVarsPerEnvironment");
|
|
276498
276540
|
__name(collectCoreBindingsPerEnvironment, "collectCoreBindingsPerEnvironment");
|
|
276499
276541
|
__name(collectDurableObjectsPerEnvironment, "collectDurableObjectsPerEnvironment");
|
|
@@ -292299,13 +292341,6 @@ var init_dev2 = __esm({
|
|
|
292299
292341
|
describe: "Show interactive dev session (defaults to true if the terminal supports interactivity)",
|
|
292300
292342
|
type: "boolean"
|
|
292301
292343
|
},
|
|
292302
|
-
"experimental-tail-logs": {
|
|
292303
|
-
type: "boolean",
|
|
292304
|
-
alias: ["x-tail-logs"],
|
|
292305
|
-
describe: "Experimental: Get runtime logs for the remote worker via Workers Tails rather than the Devtools inspector",
|
|
292306
|
-
default: true,
|
|
292307
|
-
hidden: true
|
|
292308
|
-
},
|
|
292309
292344
|
types: {
|
|
292310
292345
|
describe: "Generate types from your Worker configuration",
|
|
292311
292346
|
type: "boolean"
|
|
@@ -293197,7 +293232,7 @@ async function resolveTriggers(config, input) {
|
|
|
293197
293232
|
})) ?? [];
|
|
293198
293233
|
return [...devRoutes, ...queueConsumers, ...crons];
|
|
293199
293234
|
}
|
|
293200
|
-
async function resolveConfig(config, input) {
|
|
293235
|
+
async function resolveConfig(config, input, previousName) {
|
|
293201
293236
|
if (config.pages_build_output_dir && input.dev?.multiworkerPrimary === false) {
|
|
293202
293237
|
throw new UserError(
|
|
293203
293238
|
`You cannot use a Pages project as a service binding target.
|
|
@@ -293230,7 +293265,7 @@ If you are trying to develop Pages and Workers together, please use \`wrangler p
|
|
|
293230
293265
|
config
|
|
293231
293266
|
);
|
|
293232
293267
|
const resolved = {
|
|
293233
|
-
name: getScriptName({ name: input.name, env: input.env }, config) ??
|
|
293268
|
+
name: getScriptName({ name: input.name, env: input.env }, config) ?? previousName ?? crypto.randomUUID(),
|
|
293234
293269
|
config: config.configPath,
|
|
293235
293270
|
compatibilityDate: getDevCompatibilityDate(
|
|
293236
293271
|
entry.projectRoot,
|
|
@@ -293285,9 +293320,7 @@ If you are trying to develop Pages and Workers together, please use \`wrangler p
|
|
|
293285
293320
|
},
|
|
293286
293321
|
assets: assetsOptions,
|
|
293287
293322
|
tailConsumers: config.tail_consumers ?? [],
|
|
293288
|
-
experimental: {
|
|
293289
|
-
tailLogs: !!input.experimental?.tailLogs
|
|
293290
|
-
},
|
|
293323
|
+
experimental: {},
|
|
293291
293324
|
streamingTailConsumers: config.streaming_tail_consumers ?? []
|
|
293292
293325
|
};
|
|
293293
293326
|
if (extractBindingsOfType("analytics_engine", resolved.bindings).length && !resolved.dev.remote && resolved.build.format === "service-worker") {
|
|
@@ -293478,7 +293511,7 @@ var init_ConfigController = __esm({
|
|
|
293478
293511
|
if (!getDisableConfigWatching()) {
|
|
293479
293512
|
await this.#ensureWatchingConfig(fileConfig.configPath);
|
|
293480
293513
|
}
|
|
293481
|
-
const { config: resolvedConfig, printCurrentBindings } = await resolveConfig(fileConfig, input);
|
|
293514
|
+
const { config: resolvedConfig, printCurrentBindings } = await resolveConfig(fileConfig, input, this.latestConfig?.name);
|
|
293482
293515
|
if (signal.aborted) {
|
|
293483
293516
|
return;
|
|
293484
293517
|
}
|
|
@@ -294177,12 +294210,11 @@ var init_ProxyController = __esm({
|
|
|
294177
294210
|
}
|
|
294178
294211
|
}
|
|
294179
294212
|
get inspectorEnabled() {
|
|
294180
|
-
const inVscodeJsDebugTerminal = !!process.env.VSCODE_INSPECTOR_OPTIONS;
|
|
294181
|
-
const shouldEnableInspector = this.latestConfig?.dev.inspector !== false && !inVscodeJsDebugTerminal;
|
|
294182
294213
|
if (this.latestConfig?.dev.remote) {
|
|
294183
|
-
return
|
|
294214
|
+
return false;
|
|
294184
294215
|
}
|
|
294185
|
-
|
|
294216
|
+
const inVscodeJsDebugTerminal = !!process.env.VSCODE_INSPECTOR_OPTIONS;
|
|
294217
|
+
return this.latestConfig?.dev.inspector !== false && !inVscodeJsDebugTerminal;
|
|
294186
294218
|
}
|
|
294187
294219
|
// ******************
|
|
294188
294220
|
// Event Handlers
|
|
@@ -294367,72 +294399,72 @@ var init_ProxyController = __esm({
|
|
|
294367
294399
|
__name(didMiniflareOptionsChange, "didMiniflareOptionsChange");
|
|
294368
294400
|
}
|
|
294369
294401
|
});
|
|
294370
|
-
|
|
294371
|
-
// src/utils/isAbortError.ts
|
|
294372
|
-
function isAbortError(err) {
|
|
294373
|
-
const legacyAbortErroCheck = err.code == "ABORT_ERR";
|
|
294374
|
-
const abortErrorCheck = err instanceof Error && err.name == "AbortError";
|
|
294375
|
-
return legacyAbortErroCheck || abortErrorCheck;
|
|
294376
|
-
}
|
|
294377
|
-
var init_isAbortError = __esm({
|
|
294378
|
-
"src/utils/isAbortError.ts"() {
|
|
294379
|
-
init_import_meta_url();
|
|
294380
|
-
__name(isAbortError, "isAbortError");
|
|
294381
|
-
}
|
|
294382
|
-
});
|
|
294383
294402
|
function switchHost(originalUrl, host, zonePreview) {
|
|
294384
294403
|
const url4 = new Url.URL(originalUrl);
|
|
294385
294404
|
url4.hostname = zonePreview ? host ?? url4.hostname : url4.hostname;
|
|
294386
294405
|
return url4;
|
|
294387
294406
|
}
|
|
294388
|
-
async function
|
|
294407
|
+
async function tryExpandToken(exchangeUrl, ctx, abortSignal) {
|
|
294408
|
+
try {
|
|
294409
|
+
const switchedExchangeUrl = switchHost(exchangeUrl, ctx.host, !!ctx.zone);
|
|
294410
|
+
const headers = {};
|
|
294411
|
+
const accessToken = await getAccessToken(switchedExchangeUrl.hostname);
|
|
294412
|
+
if (accessToken) {
|
|
294413
|
+
headers.cookie = `CF_Authorization=${accessToken}`;
|
|
294414
|
+
}
|
|
294415
|
+
logger.debugWithSanitization(
|
|
294416
|
+
"-- START EXCHANGE API REQUEST:",
|
|
294417
|
+
` GET ${switchedExchangeUrl.href}`
|
|
294418
|
+
);
|
|
294419
|
+
logger.debug("-- END EXCHANGE API REQUEST");
|
|
294420
|
+
const exchangeResponse = await (0, import_undici26.fetch)(switchedExchangeUrl, {
|
|
294421
|
+
signal: abortSignal,
|
|
294422
|
+
headers
|
|
294423
|
+
});
|
|
294424
|
+
const bodyText = await exchangeResponse.text();
|
|
294425
|
+
logger.debug(
|
|
294426
|
+
"-- START EXCHANGE API RESPONSE:",
|
|
294427
|
+
exchangeResponse.statusText,
|
|
294428
|
+
exchangeResponse.status
|
|
294429
|
+
);
|
|
294430
|
+
logger.debug("HEADERS:", JSON.stringify(exchangeResponse.headers, null, 2));
|
|
294431
|
+
logger.debugWithSanitization("RESPONSE:", bodyText);
|
|
294432
|
+
logger.debug("-- END EXCHANGE API RESPONSE");
|
|
294433
|
+
if (!exchangeResponse.ok) {
|
|
294434
|
+
return null;
|
|
294435
|
+
}
|
|
294436
|
+
const body = parseJSON(bodyText);
|
|
294437
|
+
if (typeof body?.token !== "string") {
|
|
294438
|
+
return null;
|
|
294439
|
+
}
|
|
294440
|
+
return body.token;
|
|
294441
|
+
} catch (e9) {
|
|
294442
|
+
if (e9 instanceof Error && e9.name === "AbortError") {
|
|
294443
|
+
throw e9;
|
|
294444
|
+
}
|
|
294445
|
+
return null;
|
|
294446
|
+
}
|
|
294447
|
+
}
|
|
294448
|
+
async function createPreviewSession(complianceConfig, account, ctx, abortSignal, name2) {
|
|
294389
294449
|
const { accountId, apiToken } = account;
|
|
294390
294450
|
const initUrl = ctx.zone ? `/zones/${ctx.zone}/workers/edge-preview` : `/accounts/${accountId}/workers/subdomain/edge-preview`;
|
|
294391
|
-
const { exchange_url } = await fetchResult(
|
|
294392
|
-
|
|
294393
|
-
initUrl,
|
|
294394
|
-
void 0,
|
|
294395
|
-
void 0,
|
|
294396
|
-
abortSignal,
|
|
294397
|
-
apiToken
|
|
294398
|
-
);
|
|
294399
|
-
const switchedExchangeUrl = switchHost(exchange_url, ctx.host, !!ctx.zone);
|
|
294400
|
-
const headers = {};
|
|
294401
|
-
const accessToken = await getAccessToken(switchedExchangeUrl.hostname);
|
|
294402
|
-
if (accessToken) {
|
|
294403
|
-
headers.cookie = `CF_Authorization=${accessToken}`;
|
|
294404
|
-
}
|
|
294405
|
-
logger.debugWithSanitization(
|
|
294406
|
-
"-- START EXCHANGE API REQUEST:",
|
|
294407
|
-
` GET ${switchedExchangeUrl.href}`
|
|
294408
|
-
);
|
|
294409
|
-
logger.debug("-- END EXCHANGE API REQUEST");
|
|
294410
|
-
const exchangeResponse = await (0, import_undici26.fetch)(switchedExchangeUrl, {
|
|
294411
|
-
signal: abortSignal,
|
|
294412
|
-
headers
|
|
294413
|
-
});
|
|
294414
|
-
const bodyText = await exchangeResponse.text();
|
|
294415
|
-
logger.debug(
|
|
294416
|
-
"-- START EXCHANGE API RESPONSE:",
|
|
294417
|
-
exchangeResponse.statusText,
|
|
294418
|
-
exchangeResponse.status
|
|
294419
|
-
);
|
|
294420
|
-
logger.debug("HEADERS:", JSON.stringify(exchangeResponse.headers, null, 2));
|
|
294421
|
-
logger.debugWithSanitization("RESPONSE:", bodyText);
|
|
294422
|
-
logger.debug("-- END EXCHANGE API RESPONSE");
|
|
294451
|
+
const { token, exchange_url } = await fetchResult(complianceConfig, initUrl, void 0, void 0, abortSignal, apiToken);
|
|
294452
|
+
const previewSessionToken = exchange_url ? await tryExpandToken(exchange_url, ctx, abortSignal) ?? token : token;
|
|
294423
294453
|
try {
|
|
294424
|
-
|
|
294425
|
-
|
|
294426
|
-
|
|
294427
|
-
|
|
294428
|
-
|
|
294454
|
+
let host = ctx.host;
|
|
294455
|
+
if (!host) {
|
|
294456
|
+
const subdomain = await getWorkersDevSubdomain(
|
|
294457
|
+
complianceConfig,
|
|
294458
|
+
account.accountId,
|
|
294459
|
+
void 0,
|
|
294460
|
+
apiToken
|
|
294461
|
+
);
|
|
294462
|
+
host = `${name2 ?? crypto2__default.default.randomUUID()}.${subdomain}`;
|
|
294429
294463
|
}
|
|
294430
294464
|
return {
|
|
294431
|
-
|
|
294432
|
-
|
|
294433
|
-
|
|
294434
|
-
prewarmUrl: switchHost(prewarm, ctx.host, !!ctx.zone),
|
|
294435
|
-
inspectorUrl
|
|
294465
|
+
value: previewSessionToken,
|
|
294466
|
+
host,
|
|
294467
|
+
name: name2
|
|
294436
294468
|
};
|
|
294437
294469
|
} catch (e9) {
|
|
294438
294470
|
if (!(e9 instanceof ParseError)) {
|
|
@@ -294445,7 +294477,7 @@ async function createPreviewSession(complianceConfig, account, ctx, abortSignal,
|
|
|
294445
294477
|
}
|
|
294446
294478
|
}
|
|
294447
294479
|
async function createPreviewToken(complianceConfig, account, worker, ctx, session, abortSignal, minimal_mode) {
|
|
294448
|
-
const { value, host
|
|
294480
|
+
const { value, host } = session;
|
|
294449
294481
|
const { accountId } = account;
|
|
294450
294482
|
const url4 = ctx.env && ctx.useServiceEnvironments ? `/accounts/${accountId}/workers/services/${worker.name}/environments/${ctx.env}/edge-preview` : `/accounts/${accountId}/workers/scripts/${worker.name}/edge-preview`;
|
|
294451
294483
|
const mode = ctx.zone ? {
|
|
@@ -294483,9 +294515,7 @@ async function createPreviewToken(complianceConfig, account, worker, ctx, sessio
|
|
|
294483
294515
|
);
|
|
294484
294516
|
return {
|
|
294485
294517
|
value: preview_token,
|
|
294486
|
-
host
|
|
294487
|
-
inspectorUrl,
|
|
294488
|
-
prewarmUrl,
|
|
294518
|
+
host,
|
|
294489
294519
|
tailUrl: tail_url
|
|
294490
294520
|
};
|
|
294491
294521
|
}
|
|
@@ -294499,27 +294529,6 @@ async function createWorkerPreview(complianceConfig, init4, account, ctx, sessio
|
|
|
294499
294529
|
abortSignal,
|
|
294500
294530
|
minimal_mode
|
|
294501
294531
|
);
|
|
294502
|
-
const accessToken = await getAccessToken(token.prewarmUrl.hostname);
|
|
294503
|
-
const headers = { "cf-workers-preview-token": token.value };
|
|
294504
|
-
if (accessToken) {
|
|
294505
|
-
headers.cookie = `CF_Authorization=${accessToken}`;
|
|
294506
|
-
}
|
|
294507
|
-
(0, import_undici26.fetch)(token.prewarmUrl.href, {
|
|
294508
|
-
method: "POST",
|
|
294509
|
-
signal: abortSignal,
|
|
294510
|
-
headers
|
|
294511
|
-
}).then(
|
|
294512
|
-
(response) => {
|
|
294513
|
-
if (!response.ok) {
|
|
294514
|
-
logger.warn("worker failed to prewarm: ", response.statusText);
|
|
294515
|
-
}
|
|
294516
|
-
},
|
|
294517
|
-
(err) => {
|
|
294518
|
-
if (isAbortError(err)) {
|
|
294519
|
-
logger.warn("worker failed to prewarm: ", err);
|
|
294520
|
-
}
|
|
294521
|
-
}
|
|
294522
|
-
);
|
|
294523
294532
|
return token;
|
|
294524
294533
|
}
|
|
294525
294534
|
var import_undici26;
|
|
@@ -294531,14 +294540,28 @@ var init_create_worker_preview = __esm({
|
|
|
294531
294540
|
init_cfetch();
|
|
294532
294541
|
init_create_worker_upload_form();
|
|
294533
294542
|
init_logger();
|
|
294543
|
+
init_routes6();
|
|
294534
294544
|
init_access();
|
|
294535
|
-
init_isAbortError();
|
|
294536
294545
|
__name(switchHost, "switchHost");
|
|
294546
|
+
__name(tryExpandToken, "tryExpandToken");
|
|
294537
294547
|
__name(createPreviewSession, "createPreviewSession");
|
|
294538
294548
|
__name(createPreviewToken, "createPreviewToken");
|
|
294539
294549
|
__name(createWorkerPreview, "createWorkerPreview");
|
|
294540
294550
|
}
|
|
294541
294551
|
});
|
|
294552
|
+
|
|
294553
|
+
// src/utils/isAbortError.ts
|
|
294554
|
+
function isAbortError(err) {
|
|
294555
|
+
const legacyAbortErroCheck = err.code == "ABORT_ERR";
|
|
294556
|
+
const abortErrorCheck = err instanceof Error && err.name == "AbortError";
|
|
294557
|
+
return legacyAbortErroCheck || abortErrorCheck;
|
|
294558
|
+
}
|
|
294559
|
+
var init_isAbortError = __esm({
|
|
294560
|
+
"src/utils/isAbortError.ts"() {
|
|
294561
|
+
init_import_meta_url();
|
|
294562
|
+
__name(isAbortError, "isAbortError");
|
|
294563
|
+
}
|
|
294564
|
+
});
|
|
294542
294565
|
function handlePreviewSessionUploadError(err, accountId) {
|
|
294543
294566
|
assert51__default.default(err && typeof err === "object");
|
|
294544
294567
|
if (!isAbortError(err)) {
|
|
@@ -294768,7 +294791,7 @@ var init_RemoteRuntimeController = __esm({
|
|
|
294768
294791
|
workerAccount,
|
|
294769
294792
|
workerContext,
|
|
294770
294793
|
this.#abortController.signal,
|
|
294771
|
-
props.
|
|
294794
|
+
props.name
|
|
294772
294795
|
);
|
|
294773
294796
|
} catch (err) {
|
|
294774
294797
|
if (err instanceof Error && err.name == "AbortError") {
|
|
@@ -294792,6 +294815,9 @@ var init_RemoteRuntimeController = __esm({
|
|
|
294792
294815
|
if (props.bundleId !== this.#currentBundleId) {
|
|
294793
294816
|
return;
|
|
294794
294817
|
}
|
|
294818
|
+
this.#activeTail?.removeAllListeners("error");
|
|
294819
|
+
this.#activeTail?.on("error", () => {
|
|
294820
|
+
});
|
|
294795
294821
|
this.#activeTail?.terminate();
|
|
294796
294822
|
const { workerAccount, workerContext } = await getWorkerAccountAndContext(
|
|
294797
294823
|
{
|
|
@@ -294805,7 +294831,6 @@ var init_RemoteRuntimeController = __esm({
|
|
|
294805
294831
|
configPath: props.configPath
|
|
294806
294832
|
}
|
|
294807
294833
|
);
|
|
294808
|
-
const scriptId = props.name || (workerContext.zone ? this.#session.id : this.#session.host.split(".")[0]);
|
|
294809
294834
|
if (props.bundleId !== this.#currentBundleId) {
|
|
294810
294835
|
return;
|
|
294811
294836
|
}
|
|
@@ -294814,7 +294839,7 @@ var init_RemoteRuntimeController = __esm({
|
|
|
294814
294839
|
bundle: props.bundle,
|
|
294815
294840
|
modules: props.modules,
|
|
294816
294841
|
accountId: props.accountId,
|
|
294817
|
-
name:
|
|
294842
|
+
name: props.name,
|
|
294818
294843
|
useServiceEnvironments: props.useServiceEnvironments,
|
|
294819
294844
|
env: props.env,
|
|
294820
294845
|
isWorkersSite: props.isWorkersSite,
|
|
@@ -294837,7 +294862,7 @@ var init_RemoteRuntimeController = __esm({
|
|
|
294837
294862
|
this.#abortController.signal,
|
|
294838
294863
|
props.minimal_mode
|
|
294839
294864
|
);
|
|
294840
|
-
if (
|
|
294865
|
+
if (workerPreviewToken.tailUrl) {
|
|
294841
294866
|
this.#activeTail = new import_websocket.default(
|
|
294842
294867
|
workerPreviewToken.tailUrl,
|
|
294843
294868
|
TRACE_VERSION,
|
|
@@ -294885,7 +294910,7 @@ var init_RemoteRuntimeController = __esm({
|
|
|
294885
294910
|
routes,
|
|
294886
294911
|
sendMetrics: config.sendMetrics,
|
|
294887
294912
|
configPath: config.config,
|
|
294888
|
-
|
|
294913
|
+
name: config.name
|
|
294889
294914
|
});
|
|
294890
294915
|
}
|
|
294891
294916
|
#extractRoutes(config) {
|
|
@@ -294929,8 +294954,7 @@ var init_RemoteRuntimeController = __esm({
|
|
|
294929
294954
|
sendMetrics: config.sendMetrics,
|
|
294930
294955
|
configPath: config.config,
|
|
294931
294956
|
bundleId,
|
|
294932
|
-
minimal_mode: config.dev.remote === "minimal"
|
|
294933
|
-
tail_logs: !!config.experimental?.tailLogs
|
|
294957
|
+
minimal_mode: config.dev.remote === "minimal"
|
|
294934
294958
|
});
|
|
294935
294959
|
if (bundleId !== this.#currentBundleId || !token) {
|
|
294936
294960
|
return;
|
|
@@ -294946,14 +294970,6 @@ var init_RemoteRuntimeController = __esm({
|
|
|
294946
294970
|
hostname: token.host,
|
|
294947
294971
|
port: "443"
|
|
294948
294972
|
},
|
|
294949
|
-
...!config.experimental?.tailLogs && token.inspectorUrl ? {
|
|
294950
|
-
userWorkerInspectorUrl: {
|
|
294951
|
-
protocol: token.inspectorUrl.protocol,
|
|
294952
|
-
hostname: token.inspectorUrl.hostname,
|
|
294953
|
-
port: token.inspectorUrl.port.toString(),
|
|
294954
|
-
pathname: token.inspectorUrl.pathname
|
|
294955
|
-
}
|
|
294956
|
-
} : {},
|
|
294957
294973
|
headers: {
|
|
294958
294974
|
"cf-workers-preview-token": token.value,
|
|
294959
294975
|
...accessToken ? { Cookie: `CF_Authorization=${accessToken}` } : {},
|
|
@@ -294978,6 +294994,9 @@ var init_RemoteRuntimeController = __esm({
|
|
|
294978
294994
|
if (this.#session) {
|
|
294979
294995
|
logger.log(source_default.dim("\u2394 Detected changes, restarted server."));
|
|
294980
294996
|
}
|
|
294997
|
+
if (this.#session && config.name !== this.#session.name) {
|
|
294998
|
+
this.#session = void 0;
|
|
294999
|
+
}
|
|
294981
295000
|
this.#session ??= await this.#getPreviewSession(config, auth, routes);
|
|
294982
295001
|
await this.#updatePreviewToken(config, bundle, auth, routes, id);
|
|
294983
295002
|
} catch (error2) {
|
|
@@ -295068,6 +295087,9 @@ var init_RemoteRuntimeController = __esm({
|
|
|
295068
295087
|
logger.debug("RemoteRuntimeController teardown beginning...");
|
|
295069
295088
|
this.#session = void 0;
|
|
295070
295089
|
this.#abortController.abort();
|
|
295090
|
+
this.#activeTail?.removeAllListeners("error");
|
|
295091
|
+
this.#activeTail?.on("error", () => {
|
|
295092
|
+
});
|
|
295071
295093
|
this.#activeTail?.terminate();
|
|
295072
295094
|
logger.debug("RemoteRuntimeController teardown complete");
|
|
295073
295095
|
}
|
|
@@ -295767,8 +295789,7 @@ var init_LocalRuntimeController = __esm({
|
|
|
295767
295789
|
this.containerBeingBuilt = void 0;
|
|
295768
295790
|
}, "onContainerImagePreparationEnd"),
|
|
295769
295791
|
logger,
|
|
295770
|
-
isVite: false
|
|
295771
|
-
compatibilityFlags: data.config.compatibilityFlags
|
|
295792
|
+
isVite: false
|
|
295772
295793
|
});
|
|
295773
295794
|
if (this.containerBeingBuilt) {
|
|
295774
295795
|
this.containerBeingBuilt.abortRequested = false;
|
|
@@ -296034,8 +296055,7 @@ var init_MultiworkerRuntimeController = __esm({
|
|
|
296034
296055
|
this.containerBeingBuilt = void 0;
|
|
296035
296056
|
}, "onContainerImagePreparationEnd"),
|
|
296036
296057
|
logger,
|
|
296037
|
-
isVite: false
|
|
296038
|
-
compatibilityFlags: data.config.compatibilityFlags
|
|
296058
|
+
isVite: false
|
|
296039
296059
|
});
|
|
296040
296060
|
if (this.containerBeingBuilt) {
|
|
296041
296061
|
this.containerBeingBuilt.abortRequested = false;
|
|
@@ -296301,7 +296321,7 @@ function registerDevHotKeys(devEnvs, args, render2 = true) {
|
|
|
296301
296321
|
keys: ["d"],
|
|
296302
296322
|
label: "open devtools",
|
|
296303
296323
|
// Don't display this hotkey if we're in a VSCode debug session
|
|
296304
|
-
disabled: !!process.env.VSCODE_INSPECTOR_OPTIONS || args.remote
|
|
296324
|
+
disabled: !!process.env.VSCODE_INSPECTOR_OPTIONS || args.remote,
|
|
296305
296325
|
handler: /* @__PURE__ */ __name(async () => {
|
|
296306
296326
|
const { inspectorUrl } = await primaryDevEnv.proxy.ready.promise;
|
|
296307
296327
|
if (!inspectorUrl) {
|
|
@@ -298886,10 +298906,7 @@ async function setupDevEnv(devEnv, configPath, auth, args) {
|
|
|
298886
298906
|
}, "site"),
|
|
298887
298907
|
useServiceEnvironments: !(args.legacyEnv ?? true)
|
|
298888
298908
|
},
|
|
298889
|
-
assets: args.assets
|
|
298890
|
-
experimental: {
|
|
298891
|
-
tailLogs: !!args.experimentalTailLogs
|
|
298892
|
-
}
|
|
298909
|
+
assets: args.assets
|
|
298893
298910
|
},
|
|
298894
298911
|
true
|
|
298895
298912
|
);
|
|
@@ -299068,7 +299085,6 @@ unstable_dev()'s behaviour will likely change in future releases`
|
|
|
299068
299085
|
enableContainers: options?.experimental?.enableContainers ?? false,
|
|
299069
299086
|
dockerPath,
|
|
299070
299087
|
containerEngine: options?.experimental?.containerEngine,
|
|
299071
|
-
experimentalTailLogs: true,
|
|
299072
299088
|
types: false
|
|
299073
299089
|
};
|
|
299074
299090
|
const devServer = await run(
|