@cloudflare/vitest-pool-workers 0.16.4 → 0.16.6
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/dist/pool/index.mjs +48 -23
- package/dist/pool/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/pool/index.mjs
CHANGED
|
@@ -461,7 +461,7 @@ var MetricsRegistry = class {
|
|
|
461
461
|
};
|
|
462
462
|
|
|
463
463
|
//#endregion
|
|
464
|
-
//#region ../workers-utils/dist/chunk-
|
|
464
|
+
//#region ../workers-utils/dist/chunk-GMTGAG26.mjs
|
|
465
465
|
var UserError = class extends Error {
|
|
466
466
|
static {
|
|
467
467
|
__name(this, "UserError");
|
|
@@ -2858,8 +2858,15 @@ function findRedirectedWranglerConfig(cwd, userConfigPath) {
|
|
|
2858
2858
|
};
|
|
2859
2859
|
}
|
|
2860
2860
|
__name(findRedirectedWranglerConfig, "findRedirectedWranglerConfig");
|
|
2861
|
+
function isRedirectedConfig(config) {
|
|
2862
|
+
return config.configPath !== void 0 && config.configPath !== config.userConfigPath;
|
|
2863
|
+
}
|
|
2864
|
+
__name(isRedirectedConfig, "isRedirectedConfig");
|
|
2861
2865
|
function isRedirectedRawConfig(rawConfig, configPath, userConfigPath) {
|
|
2862
|
-
return
|
|
2866
|
+
return isRedirectedConfig({
|
|
2867
|
+
configPath,
|
|
2868
|
+
userConfigPath
|
|
2869
|
+
});
|
|
2863
2870
|
}
|
|
2864
2871
|
__name(isRedirectedRawConfig, "isRedirectedRawConfig");
|
|
2865
2872
|
function configFormat(configPath) {
|
|
@@ -7707,9 +7714,9 @@ function normalizeAndValidateConfig(rawConfig, configPath, userConfigPath, args,
|
|
|
7707
7714
|
if (useServiceEnvironments) diagnostics.warnings.push("Service environments are deprecated, and will be removed in the future. DO NOT USE IN PRODUCTION.");
|
|
7708
7715
|
const isDispatchNamespace = typeof args["dispatch-namespace"] === "string" && args["dispatch-namespace"].trim() !== "";
|
|
7709
7716
|
const topLevelEnv = normalizeAndValidateEnvironment(diagnostics, configPath, rawConfig, isDispatchNamespace, preserveOriginalMain);
|
|
7710
|
-
const
|
|
7717
|
+
const isRedirectedConfig2 = isRedirectedRawConfig(rawConfig, configPath, userConfigPath);
|
|
7711
7718
|
const definedEnvironments = Object.keys(rawConfig.env ?? {});
|
|
7712
|
-
if (
|
|
7719
|
+
if (isRedirectedConfig2 && definedEnvironments.length > 0) diagnostics.errors.push(dedent`
|
|
7713
7720
|
Redirected configurations cannot include environments but the following have been found:\n${definedEnvironments.map((env) => ` - ${env}`).join("\n")}
|
|
7714
7721
|
|
|
7715
7722
|
|
|
@@ -7720,7 +7727,7 @@ function normalizeAndValidateConfig(rawConfig, configPath, userConfigPath, args,
|
|
|
7720
7727
|
const envName = args.env ?? getCloudflareEnv();
|
|
7721
7728
|
assert(envName === void 0 || typeof envName === "string");
|
|
7722
7729
|
let activeEnv = topLevelEnv;
|
|
7723
|
-
if (envName) if (
|
|
7730
|
+
if (envName) if (isRedirectedConfig2) {
|
|
7724
7731
|
if (!isPagesConfig(rawConfig) && rawConfig.targetEnvironment && rawConfig.targetEnvironment !== envName) {
|
|
7725
7732
|
const via = args.env !== void 0 ? "via the `--env/-e` CLI argument" : "via the CLOUDFLARE_ENV environment variable";
|
|
7726
7733
|
throw new Error(dedent`
|
|
@@ -7752,9 +7759,9 @@ Consider adding an environment configuration section to the ${configFileName(con
|
|
|
7752
7759
|
const config = {
|
|
7753
7760
|
configPath,
|
|
7754
7761
|
userConfigPath,
|
|
7755
|
-
topLevelName:
|
|
7756
|
-
definedEnvironments:
|
|
7757
|
-
targetEnvironment:
|
|
7762
|
+
topLevelName: isRedirectedConfig2 ? rawConfig.topLevelName : rawConfig.name,
|
|
7763
|
+
definedEnvironments: isRedirectedConfig2 ? rawConfig.definedEnvironments : definedEnvironments,
|
|
7764
|
+
targetEnvironment: isRedirectedConfig2 ? rawConfig.targetEnvironment : envName,
|
|
7758
7765
|
pages_build_output_dir: normalizeAndValidatePagesBuildOutputDir(configPath, rawConfig.pages_build_output_dir),
|
|
7759
7766
|
legacy_env: !useServiceEnvironments,
|
|
7760
7767
|
send_metrics: rawConfig.send_metrics,
|
|
@@ -8083,7 +8090,7 @@ var validateStreamingTailConsumers = /* @__PURE__ */ __name((diagnostics, field,
|
|
|
8083
8090
|
}, "validateStreamingTailConsumers");
|
|
8084
8091
|
function normalizeAndValidateEnvironment(diagnostics, configPath, rawEnv, isDispatchNamespace, preserveOriginalMain, envName = "top level", topLevelEnv, useServiceEnvironments, rawConfig) {
|
|
8085
8092
|
deprecated(diagnostics, rawEnv, "node_compat", `The "node_compat" field is no longer supported as of Wrangler v4. Instead, use the \`nodejs_compat\` compatibility flag. This includes the functionality from legacy \`node_compat\` polyfills and natively implemented Node.js APIs. See https://developers.cloudflare.com/workers/runtime-apis/nodejs for more information.`, true, "Removed", "error");
|
|
8086
|
-
experimental(diagnostics, rawEnv, "unsafe");
|
|
8093
|
+
if (topLevelEnv === void 0 || rawConfig?.unsafe === void 0) experimental(diagnostics, rawEnv, "unsafe");
|
|
8087
8094
|
const route = normalizeAndValidateRoute(diagnostics, topLevelEnv, rawEnv);
|
|
8088
8095
|
const account_id = inheritableInWranglerEnvironments(diagnostics, useServiceEnvironments, topLevelEnv, mutateEmptyStringAccountIDValue(diagnostics, rawEnv), "account_id", isString, void 0, void 0);
|
|
8089
8096
|
const routes = validateRoutes(diagnostics, topLevelEnv, rawEnv);
|
|
@@ -8246,9 +8253,11 @@ var validateDefines = /* @__PURE__ */ __name((envName) => (diagnostics, field, v
|
|
|
8246
8253
|
if (configDefines.length > 0) {
|
|
8247
8254
|
if (typeof value === "object" && value !== null) {
|
|
8248
8255
|
const configEnvDefines = config === void 0 ? [] : Object.keys(value);
|
|
8249
|
-
|
|
8250
|
-
|
|
8251
|
-
|
|
8256
|
+
const missingDefines = configDefines.filter((varName) => !(varName in value));
|
|
8257
|
+
if (missingDefines.length > 0) diagnostics.warnings.push(`The following define entries exist at the top level, but not on "${fieldPath}".
|
|
8258
|
+
This is probably not what you want, since "define" configuration is not inherited by environments.
|
|
8259
|
+
Please add these entries to "env.${envName}.define":
|
|
8260
|
+
` + missingDefines.map((varName) => `- ${varName}`).join("\n"));
|
|
8252
8261
|
for (const varName of configEnvDefines) if (!configDefines.includes(varName)) diagnostics.warnings.push(`"${varName}" exists on "env.${envName}", but not on the top level.
|
|
8253
8262
|
This is not what you probably want, since "define" configuration within environments can only override existing top level "define" configuration
|
|
8254
8263
|
Please remove "${fieldPath}.${varName}", or add "define.${varName}".`);
|
|
@@ -8272,9 +8281,11 @@ var validateVars = /* @__PURE__ */ __name((envName) => (diagnostics, field, valu
|
|
|
8272
8281
|
const configVars = Object.keys(config?.vars ?? {});
|
|
8273
8282
|
if (configVars.length > 0) {
|
|
8274
8283
|
if (typeof value === "object" && value !== null) {
|
|
8275
|
-
|
|
8276
|
-
|
|
8277
|
-
|
|
8284
|
+
const missingVars = configVars.filter((varName) => !(varName in value));
|
|
8285
|
+
if (missingVars.length > 0) diagnostics.warnings.push(`The following vars exist at the top level, but not on "${fieldPath}".
|
|
8286
|
+
This is probably not what you want, since "vars" configuration is not inherited by environments.
|
|
8287
|
+
Please add these vars to "env.${envName}.vars":
|
|
8288
|
+
` + missingVars.map((varName) => `- ${varName}`).join("\n"));
|
|
8278
8289
|
}
|
|
8279
8290
|
}
|
|
8280
8291
|
return isValid2;
|
|
@@ -10295,27 +10306,36 @@ function startTunnel(options) {
|
|
|
10295
10306
|
const timeoutMs = options.timeoutMs ?? TUNNEL_STARTUP_TIMEOUT_MS;
|
|
10296
10307
|
const reminderIntervalMs = options.reminderIntervalMs ?? DEFAULT_TUNNEL_REMINDER_INTERVAL_MS;
|
|
10297
10308
|
const defaultExpiryMs = options.expiryMs ?? DEFAULT_TUNNEL_EXPIRY_MS;
|
|
10309
|
+
const isNamedTunnel = options.token !== void 0;
|
|
10298
10310
|
const timeFormatter = new Intl.DateTimeFormat(void 0, { timeStyle: "short" });
|
|
10299
|
-
const readyPromise = spawnCloudflared([
|
|
10311
|
+
const readyPromise = spawnCloudflared(isNamedTunnel ? [
|
|
10312
|
+
"tunnel",
|
|
10313
|
+
"--no-autoupdate",
|
|
10314
|
+
"run"
|
|
10315
|
+
] : [
|
|
10300
10316
|
"tunnel",
|
|
10301
10317
|
"--no-autoupdate",
|
|
10302
10318
|
"--url",
|
|
10303
10319
|
options.origin.href
|
|
10304
10320
|
], {
|
|
10305
10321
|
stdio: "pipe",
|
|
10322
|
+
env: options.token ? { TUNNEL_TOKEN: options.token } : void 0,
|
|
10306
10323
|
skipVersionCheck: true,
|
|
10307
10324
|
logger
|
|
10308
10325
|
}).then((process2) => {
|
|
10309
10326
|
cloudflaredProcess = process2;
|
|
10310
10327
|
if (disposed) terminateCloudflared(process2);
|
|
10311
10328
|
return process2;
|
|
10312
|
-
}).then((process2) =>
|
|
10313
|
-
|
|
10314
|
-
|
|
10315
|
-
|
|
10329
|
+
}).then((process2) => {
|
|
10330
|
+
if (isNamedTunnel) return { mode: "named" };
|
|
10331
|
+
return waitForQuickTunnelReady(process2, timeoutMs, {
|
|
10332
|
+
logger,
|
|
10333
|
+
origin: options.origin
|
|
10334
|
+
});
|
|
10335
|
+
}).then((result) => {
|
|
10316
10336
|
expiresAt = Date.now() + defaultExpiryMs;
|
|
10317
10337
|
scheduleExpiryTimeout();
|
|
10318
|
-
scheduleReminder(result.publicUrl.origin);
|
|
10338
|
+
scheduleReminder(result.mode === "quick" ? result.publicUrl.origin : void 0);
|
|
10319
10339
|
return result;
|
|
10320
10340
|
});
|
|
10321
10341
|
function disposeTunnel() {
|
|
@@ -10341,7 +10361,7 @@ function startTunnel(options) {
|
|
|
10341
10361
|
if (disposed) return;
|
|
10342
10362
|
const remainingMs = expiresAt - Date.now();
|
|
10343
10363
|
if (remainingMs <= 0) return;
|
|
10344
|
-
logger?.log(`The tunnel is still open at ${publicURL}. It expires in ${formatTunnelDuration(remainingMs)}. ${options.extendHint ?? ""}`);
|
|
10364
|
+
logger?.log(`${publicURL ? `The tunnel is still open at ${publicURL}.` : "The tunnel is still open."} It expires in ${formatTunnelDuration(remainingMs)}. ${options.extendHint ?? ""}`);
|
|
10345
10365
|
}, reminderIntervalMs);
|
|
10346
10366
|
reminderInterval.unref?.();
|
|
10347
10367
|
}
|
|
@@ -10375,6 +10395,7 @@ function startTunnel(options) {
|
|
|
10375
10395
|
__name(extendExpiry, "extendExpiry");
|
|
10376
10396
|
return {
|
|
10377
10397
|
ready: /* @__PURE__ */ __name(() => readyPromise, "ready"),
|
|
10398
|
+
isOpen: /* @__PURE__ */ __name(() => !disposed, "isOpen"),
|
|
10378
10399
|
dispose: disposeTunnel,
|
|
10379
10400
|
extendExpiry
|
|
10380
10401
|
};
|
|
@@ -10420,7 +10441,10 @@ function waitForQuickTunnelReady(cloudflared, timeoutMs, options) {
|
|
|
10420
10441
|
if (match && !resolved) {
|
|
10421
10442
|
resolved = true;
|
|
10422
10443
|
clearTimeout(timeoutId);
|
|
10423
|
-
resolve$2({
|
|
10444
|
+
resolve$2({
|
|
10445
|
+
mode: "quick",
|
|
10446
|
+
publicUrl: new URL(match[0])
|
|
10447
|
+
});
|
|
10424
10448
|
}
|
|
10425
10449
|
});
|
|
10426
10450
|
cloudflared.on("error", (error) => {
|
|
@@ -13049,6 +13073,7 @@ const ignoreMessages = [
|
|
|
13049
13073
|
"disconnected: operation canceled",
|
|
13050
13074
|
"disconnected: worker_do_not_log; Request failed due to internal error",
|
|
13051
13075
|
"disconnected: WebSocket was aborted",
|
|
13076
|
+
"disconnected: WebSocket peer disconnected",
|
|
13052
13077
|
"CODE_MOVED for unknown code block",
|
|
13053
13078
|
"broken.outputGateBroken; jsg.Error: Instance dispose"
|
|
13054
13079
|
];
|