From 95852c304716e8b9b97ef2a5486c8337cc278f1d Mon Sep 17 00:00:00 2001 From: Sunil Pai Date: Tue, 17 May 2022 11:42:07 +0100 Subject: [PATCH] fix: don't fetch migrations when in `--dry-run` mode (#1039) Fixes https://github.com/cloudflare/wrangler2/issues/1038 --- .changeset/lazy-sheep-rest.md | 7 +++++++ packages/wrangler/src/__tests__/publish.test.ts | 9 ++++++++- packages/wrangler/src/publish.ts | 2 +- 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 .changeset/lazy-sheep-rest.md diff --git a/.changeset/lazy-sheep-rest.md b/.changeset/lazy-sheep-rest.md new file mode 100644 index 000000000000..ed49149ed60a --- /dev/null +++ b/.changeset/lazy-sheep-rest.md @@ -0,0 +1,7 @@ +--- +"wrangler": patch +--- + +fix: don't fetch migrations when in `--dry-run` mode + +Fixes https://github.com/cloudflare/wrangler2/issues/1038 diff --git a/packages/wrangler/src/__tests__/publish.test.ts b/packages/wrangler/src/__tests__/publish.test.ts index aa8ccd3d5ff3..926a5e79e4d4 100644 --- a/packages/wrangler/src/__tests__/publish.test.ts +++ b/packages/wrangler/src/__tests__/publish.test.ts @@ -4668,7 +4668,14 @@ addEventListener('fetch', event => {});` describe("--dry-run", () => { it("should not publish the worker if --dry-run is specified", async () => { - writeWranglerToml(); + writeWranglerToml({ + // add a durable object with migrations + // to make sure we _don't_ fetch migration status + durable_objects: { + bindings: [{ name: "NAME", class_name: "SomeClass" }], + }, + migrations: [{ tag: "v1", new_classes: ["SomeClass"] }], + }); writeWorkerSource(); await runWrangler("publish index.js --dry-run"); expect(std).toMatchInlineSnapshot(` diff --git a/packages/wrangler/src/publish.ts b/packages/wrangler/src/publish.ts index 059f41458fd9..a327f6729c6c 100644 --- a/packages/wrangler/src/publish.ts +++ b/packages/wrangler/src/publish.ts @@ -164,7 +164,7 @@ export default async function publish(props: Props): Promise { // if config.migrations let migrations; - if (config.migrations.length > 0) { + if (!props.dryRun && config.migrations.length > 0) { // get current migration tag type ScriptData = { id: string; migration_tag?: string }; let script: ScriptData | undefined;