Skip to content

Commit

Permalink
Warn when attempting to set limits and standard is not enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewdavidrodgers committed Oct 18, 2023
1 parent 2ea0049 commit 1032d6a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
28 changes: 28 additions & 0 deletions packages/wrangler/src/__tests__/standard-pricing.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,34 @@ describe("standard-pricing", () => {
}
`);
});
it("should warn user about limits set if not enabled", async () => {
msw.use(...mswSuccessDeploymentScriptMetadata);
writeWranglerToml({ limits: { cpu_ms: 20_000 } });
writeWorkerSource();
mockSubDomainRequest();
mockUploadWorkerRequest();

mockStandardEnabled(false);

await runWrangler("deploy ./index");

expect(std).toMatchInlineSnapshot(`
Object {
"debug": "",
"err": "",
"info": "",
"out": "🚧 New Workers Standard pricing is now available. Please visit the dashboard to view details and opt-in to new pricing: https://dash.cloudflare.com/some-account-id/workers/standard/opt-in.
Total Upload: xx KiB / gzip: xx KiB
Uploaded test-name (TIMINGS)
Published test-name (TIMINGS)
https://test-name.test-sub-domain.workers.dev
Current Deployment ID: Galaxy-Class",
"warn": "▲ [WARNING] The \`limits\` defined in wrangler.toml can only be applied to scripts opted into Workers Standard pricing. Agree to the new pricing details to set limits for your script.
",
}
`);
});
it("should not notify user about new pricing if enterprise", async () => {
msw.use(...mswSuccessDeploymentScriptMetadata);
writeWranglerToml();
Expand Down
5 changes: 5 additions & 0 deletions packages/wrangler/src/deploy/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ async function standardPricingWarning(
`🚧 New Workers Standard pricing is now available. Please visit the dashboard to view details and opt-in to new pricing: https://dash.cloudflare.com/${accountId}/workers/standard/opt-in.`
)
);
if (config.limits?.cpu_ms !== undefined) {
logger.warn(
"The `limits` defined in wrangler.toml can only be applied to scripts opted into Workers Standard pricing. Agree to the new pricing details to set limits for your script."
);
}
return;
}
if (standard && config.usage_model !== undefined) {
Expand Down

0 comments on commit 1032d6a

Please sign in to comment.