Skip to content
Closed
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
15 changes: 15 additions & 0 deletions packages/cloudflare/src/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,16 @@ export async function deployWithCdnWarmup(
"Configure that adapter capability or rerun without --warm-cdn-strict.",
);
}
if (
options.warmCdnPromote === false &&
paths.length > 0 &&
options.expectedBuildId === undefined
) {
throw new Error(
"CDN warmup cannot skip promotion because the discovered HTML requests cannot be verified. " +
"Configure a CDN adapter that declares build-identity response headers.",
);
}
const upload = runWranglerVersionUpload(root, options);
const warmUploadedVersion = (
targetUrl: string,
Expand Down Expand Up @@ -1116,6 +1126,11 @@ export async function deploy(options: DeployOptions): Promise<void> {
warmCdnPromotionDelay: options.warmCdnPromotionDelay,
});
} else {
if (options.warmCdnPromote === false) {
throw new Error(
"CDN warmup cannot skip promotion because no build-discovered requests were found to warm.",
);
}
console.log("\n CDN warmup skipped: no build-discovered paths found.");
url = await runWranglerDeploy(root, wranglerOptions);
}
Expand Down
12 changes: 12 additions & 0 deletions tests/cloudflare-cdn-warm-deploy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,18 @@ describe("Cloudflare CDN warmup deploy flow", () => {
expect(fetch).not.toHaveBeenCalled();
});

it("rejects no-promote HTML warmup without verifiable build identity before upload", async () => {
const { deployWithCdnWarmup } = await import("../packages/cloudflare/src/deploy.js");

await expect(
deployWithCdnWarmup(tmpDir, ["/about"], {
warmCdnPromote: false,
}),
).rejects.toThrow("discovered HTML requests cannot be verified");
expect(execFileSyncMock).not.toHaveBeenCalled();
expect(fetch).not.toHaveBeenCalled();
});

it("applies triggers before post-promotion fallback warmup", async () => {
const events: string[] = [];
writeFile(
Expand Down
15 changes: 15 additions & 0 deletions tests/deploy-prerender-config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -414,4 +414,19 @@ describe("deploy prerender config wiring", () => {
"deploy",
]);
});

it("rejects no-promote warmup when discovery finds no requests", async () => {
writeApiOnlyProject();
const { deploy } = await import("../packages/cloudflare/src/deploy.js");

await expect(
deploy({
root: tmpDir,
skipBuild: true,
warmCdnCache: true,
warmCdnPromote: false,
}),
).rejects.toThrow("no build-discovered requests were found to warm");
expect(spawn).not.toHaveBeenCalled();
});
});
Loading