From 1032d6a617c9d076397b51d0ff93a222cb2049dc Mon Sep 17 00:00:00 2001 From: Matthew Rodgers Date: Wed, 18 Oct 2023 10:39:51 -0700 Subject: [PATCH] Warn when attempting to set limits and standard is not enabled --- .../src/__tests__/standard-pricing.test.ts | 28 +++++++++++++++++++ packages/wrangler/src/deploy/index.ts | 5 ++++ 2 files changed, 33 insertions(+) diff --git a/packages/wrangler/src/__tests__/standard-pricing.test.ts b/packages/wrangler/src/__tests__/standard-pricing.test.ts index 72c28f8bb2ea..93508756b5c0 100644 --- a/packages/wrangler/src/__tests__/standard-pricing.test.ts +++ b/packages/wrangler/src/__tests__/standard-pricing.test.ts @@ -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(); diff --git a/packages/wrangler/src/deploy/index.ts b/packages/wrangler/src/deploy/index.ts index 327226056569..201e9bd27296 100644 --- a/packages/wrangler/src/deploy/index.ts +++ b/packages/wrangler/src/deploy/index.ts @@ -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) {