Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/real-regions-crash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"wrangler": patch
---

Do not show subdomain status mismatch warnings on first deploy.
130 changes: 130 additions & 0 deletions packages/wrangler/e2e/deploy.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
import dedent from "ts-dedent";
import { afterAll, beforeAll, describe, expect, it } from "vitest";
import { CLOUDFLARE_ACCOUNT_ID } from "./helpers/account-id";
import { WranglerE2ETestHelper } from "./helpers/e2e-wrangler-test";
import { generateResourceName } from "./helpers/generate-resource-name";
import { normalizeOutput } from "./helpers/normalize";

const TIMEOUT = 50_000;
const workerName = generateResourceName();
const normalize = (str: string) =>
normalizeOutput(str, {
[CLOUDFLARE_ACCOUNT_ID]: "CLOUDFLARE_ACCOUNT_ID",
}).replaceAll(/^Author:.*$/gm, "Author: [email protected]");

describe.skipIf(!CLOUDFLARE_ACCOUNT_ID)("deploy", { timeout: TIMEOUT }, () => {
let helper: WranglerE2ETestHelper;
beforeAll(async () => {
helper = new WranglerE2ETestHelper();
});

describe("subdomain warnings", () => {
beforeAll(async () => {
await helper.seed({
"wrangler.toml": dedent`
name = "${workerName}"
main = "src/index.ts"
compatibility_date = "2023-01-01"
`,
"src/index.ts": dedent`
export default {
fetch(request) {
return new Response("Hello World!")
}
}
`,
"package.json": dedent`
{
"name": "${workerName}",
"version": "0.0.0",
"private": true
}
`,
});
});

afterAll(async () => {
await helper.run(`wrangler delete`);
});

it("omit subdomain warnings on 1st deploy", async () => {
const deploy = await helper.run("wrangler deploy");
expect(normalize(deploy.stdout)).toMatchInlineSnapshot(`
"Total Upload: xx KiB / gzip: xx KiB
Uploaded tmp-e2e-worker-00000000-0000-0000-0000-000000000000 (TIMINGS)
Deployed tmp-e2e-worker-00000000-0000-0000-0000-000000000000 triggers (TIMINGS)
https://tmp-e2e-worker-00000000-0000-0000-0000-000000000000.SUBDOMAIN.workers.dev
Current Version ID: 00000000-0000-0000-0000-000000000000"
`);
expect(normalize(deploy.stderr)).toMatchInlineSnapshot(`""`);
});

it("show subdomain warnings on 2nd deploy, remote enabled", async () => {
// Set remote state.
await helper.seed({
"wrangler.toml": dedent`
name = "${workerName}"
main = "src/index.ts"
compatibility_date = "2023-01-01"
workers_dev = true
preview_urls = true
`,
});
await helper.run("wrangler triggers deploy");
// Run deploy.
await helper.seed({
"wrangler.toml": dedent`
name = "${workerName}"
main = "src/index.ts"
compatibility_date = "2023-01-01"
`,
});
const deploy = await helper.run("wrangler deploy");
expect(normalize(deploy.stdout)).toMatchInlineSnapshot(`
"Total Upload: xx KiB / gzip: xx KiB
Uploaded tmp-e2e-worker-00000000-0000-0000-0000-000000000000 (TIMINGS)
Deployed tmp-e2e-worker-00000000-0000-0000-0000-000000000000 triggers (TIMINGS)
https://tmp-e2e-worker-00000000-0000-0000-0000-000000000000.SUBDOMAIN.workers.dev
Current Version ID: 00000000-0000-0000-0000-000000000000"
`);
expect(normalize(deploy.stderr)).toMatchInlineSnapshot(`
"▲ [WARNING] Worker has preview URLs enabled, but 'preview_urls' is not in the config.
Using fallback value 'preview_urls = false'."
`);
});

it("show subdomain warnings on 3rd deploy, remote disabled", async () => {
// Set remote state.
await helper.seed({
"wrangler.toml": dedent`
name = "${workerName}"
main = "src/index.ts"
compatibility_date = "2023-01-01"
workers_dev = false
preview_urls = false
`,
});
await helper.run("wrangler triggers deploy");
// Run deploy.
await helper.seed({
"wrangler.toml": dedent`
name = "${workerName}"
main = "src/index.ts"
compatibility_date = "2023-01-01"
`,
});
const deploy = await helper.run("wrangler deploy");
expect(normalize(deploy.stdout)).toMatchInlineSnapshot(`
"Total Upload: xx KiB / gzip: xx KiB
Uploaded tmp-e2e-worker-00000000-0000-0000-0000-000000000000 (TIMINGS)
Deployed tmp-e2e-worker-00000000-0000-0000-0000-000000000000 triggers (TIMINGS)
https://tmp-e2e-worker-00000000-0000-0000-0000-000000000000.SUBDOMAIN.workers.dev
Current Version ID: 00000000-0000-0000-0000-000000000000"
`);
expect(normalize(deploy.stderr)).toMatchInlineSnapshot(`
"▲ [WARNING] Worker has workers.dev disabled, but 'workers_dev' is not in the config.
Using fallback value 'workers_dev = true'."
`);
});
});
});
52 changes: 43 additions & 9 deletions packages/wrangler/e2e/versions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ describe.skipIf(!CLOUDFLARE_ACCOUNT_ID)(
name = "${workerName}"
main = "src/index.ts"
compatibility_date = "2023-01-01"
preview_urls = true
`,
"src/index.ts": dedent`
export default {
Expand Down Expand Up @@ -70,7 +69,6 @@ describe.skipIf(!CLOUDFLARE_ACCOUNT_ID)(
Worker Startup Time: (TIMINGS)
Uploaded tmp-e2e-worker-00000000-0000-0000-0000-000000000000 (TIMINGS)
Worker Version ID: 00000000-0000-0000-0000-000000000000
Version Preview URL: https://tmp-e2e-worker-PREVIEW-URL.SUBDOMAIN.workers.dev
To deploy this version to production traffic use the command wrangler versions deploy
Changes to non-versioned settings (config properties 'logpush' or 'tail_consumers') take effect after your next deployment using the command wrangler versions deploy
Changes to triggers (routes, custom domains, cron schedules, etc) must be applied with the command wrangler triggers deploy"
Expand Down Expand Up @@ -186,7 +184,6 @@ describe.skipIf(!CLOUDFLARE_ACCOUNT_ID)(
Worker Startup Time: (TIMINGS)
Uploaded tmp-e2e-worker-00000000-0000-0000-0000-000000000000 (TIMINGS)
Worker Version ID: 00000000-0000-0000-0000-000000000000
Version Preview URL: https://tmp-e2e-worker-PREVIEW-URL.SUBDOMAIN.workers.dev
To deploy this version to production traffic use the command wrangler versions deploy
Changes to non-versioned settings (config properties 'logpush' or 'tail_consumers') take effect after your next deployment using the command wrangler versions deploy
Changes to triggers (routes, custom domains, cron schedules, etc) must be applied with the command wrangler triggers deploy"
Expand Down Expand Up @@ -590,7 +587,6 @@ describe.skipIf(!CLOUDFLARE_ACCOUNT_ID)(
Worker Startup Time: (TIMINGS)
Uploaded tmp-e2e-worker-00000000-0000-0000-0000-000000000000 (TIMINGS)
Worker Version ID: 00000000-0000-0000-0000-000000000000
Version Preview URL: https://tmp-e2e-worker-PREVIEW-URL.SUBDOMAIN.workers.dev
To deploy this version to production traffic use the command wrangler versions deploy
Changes to non-versioned settings (config properties 'logpush' or 'tail_consumers') take effect after your next deployment using the command wrangler versions deploy
Changes to triggers (routes, custom domains, cron schedules, etc) must be applied with the command wrangler triggers deploy"
Expand Down Expand Up @@ -632,7 +628,6 @@ describe.skipIf(!CLOUDFLARE_ACCOUNT_ID)(
Worker Startup Time: (TIMINGS)
Uploaded tmp-e2e-worker-00000000-0000-0000-0000-000000000000 (TIMINGS)
Worker Version ID: 00000000-0000-0000-0000-000000000000
Version Preview URL: https://tmp-e2e-worker-PREVIEW-URL.SUBDOMAIN.workers.dev
To deploy this version to production traffic use the command wrangler versions deploy
Changes to non-versioned settings (config properties 'logpush' or 'tail_consumers') take effect after your next deployment using the command wrangler versions deploy
Changes to triggers (routes, custom domains, cron schedules, etc) must be applied with the command wrangler triggers deploy"
Expand All @@ -653,6 +648,45 @@ describe.skipIf(!CLOUDFLARE_ACCOUNT_ID)(
`);
});

it("should upload version of Worker with preview_urls enabled", async () => {
await helper.seed({
"wrangler.toml": dedent`
name = "${workerName}"
main = "src/index.ts"
compatibility_date = "2023-01-01"
preview_urls = true
`,
"src/index.ts": dedent`
export default {
fetch(request) {
return new Response("Hello World!")
}
}
`,
"package.json": dedent`
{
"name": "${workerName}",
"version": "0.0.0",
"private": true
}
`,
});
await helper.run("wrangler triggers deploy");
const upload = await helper.run(
`wrangler versions upload --message "Upload via e2e test" --tag "e2e-version-with-preview"`
);
expect(normalize(upload.stdout)).toMatchInlineSnapshot(`
"Total Upload: xx KiB / gzip: xx KiB
Worker Startup Time: (TIMINGS)
Uploaded tmp-e2e-worker-00000000-0000-0000-0000-000000000000 (TIMINGS)
Worker Version ID: 00000000-0000-0000-0000-000000000000
Version Preview URL: https://tmp-e2e-worker-PREVIEW-URL.SUBDOMAIN.workers.dev
To deploy this version to production traffic use the command wrangler versions deploy
Changes to non-versioned settings (config properties 'logpush' or 'tail_consumers') take effect after your next deployment using the command wrangler versions deploy
Changes to triggers (routes, custom domains, cron schedules, etc) must be applied with the command wrangler triggers deploy"
`);
});

it("should include version preview url in output file", async () => {
const outputFile = path.join(helper.tmpPath, "output.jsonnd");
const upload = await helper.run(
Expand All @@ -678,10 +712,10 @@ describe.skipIf(!CLOUDFLARE_ACCOUNT_ID)(
const { stdout } = await helper.run(`wrangler delete`);

expect(normalize(stdout)).toMatchInlineSnapshot(`
"? Are you sure you want to delete tmp-e2e-worker-00000000-0000-0000-0000-000000000000? This action cannot be undone.
🤖 Using fallback value in non-interactive context: yes
Successfully deleted tmp-e2e-worker-00000000-0000-0000-0000-000000000000"
`);
"? Are you sure you want to delete tmp-e2e-worker-00000000-0000-0000-0000-000000000000? This action cannot be undone.
🤖 Using fallback value in non-interactive context: yes
Successfully deleted tmp-e2e-worker-00000000-0000-0000-0000-000000000000"
`);
});
}
);
1 change: 1 addition & 0 deletions packages/wrangler/src/deploy/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1098,6 +1098,7 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
// deploy triggers
const targets = await triggersDeploy({
...props,
firstDeploy: !workerExists,
routes: allDeploymentRoutes,
});

Expand Down
11 changes: 7 additions & 4 deletions packages/wrangler/src/triggers/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type Props = {
legacyEnv: boolean | undefined;
dryRun: boolean | undefined;
assetsOptions: AssetsOptions | undefined;
firstDeploy?: boolean;
};

export default async function triggersDeploy(
Expand Down Expand Up @@ -90,7 +91,8 @@ export default async function triggersDeploy(
envName,
workerUrl,
routes,
deployments
deployments,
props.firstDeploy ?? false
);

if (!wantWorkersDev && workersDevInSync && routes.length !== 0) {
Expand Down Expand Up @@ -315,7 +317,8 @@ async function subdomainDeploy(
envName: string,
workerUrl: string,
routes: Route[],
deployments: Array<Promise<string[]>>
deployments: Array<Promise<string[]>>,
firstDeploy: boolean
) {
const { config } = props;

Expand All @@ -338,7 +341,7 @@ async function subdomainDeploy(

// Warn about mismatching config and current values.

if (config.workers_dev == undefined && !workersDevInSync) {
if (!firstDeploy && config.workers_dev == undefined && !workersDevInSync) {
const currWorkersDevStatus = currWorkersDev ? "enabled" : "disabled";
logger.warn(
[
Expand All @@ -348,7 +351,7 @@ async function subdomainDeploy(
);
}

if (config.preview_urls == undefined && !previewsInSync) {
if (!firstDeploy && config.preview_urls == undefined && !previewsInSync) {
const currPreviewsStatus = currPreviews ? "enabled" : "disabled";
logger.warn(
[
Expand Down
Loading