History

Make the per-org execution rate limit env-configurable

Add an optional EXECUTION_RATE_LIMIT_PER_HOUR override, parsed as a positive integer and falling back to the 1000/hour default when unset or unparseable. Production leaves it unset; it exists so e2e can drive the abuse backstop with a handful of real executions instead of a thousand. The e2e cloud dev server sets it to 3, reaching the worker the same way ALLOW_LOCAL_NETWORK does.

Rhys Sullivan committed 4 months ago

Commit 6f5df291 parent d37ea8a2 files · +12 −0Browse files

Unified · Split

2 files
  1. apps/cloud/src/env-augment.d.ts +7 −0
  2. e2e/setup/cloud.boot.ts +5 −0
apps/cloud/src/env-augment.d.ts+7−0
@@ -39,6 +39,13 @@ declare global { · 38 unmodified lines
39 // limiter degrades to disabled when absent.39 // limiter degrades to disabled when absent.
40 EXECUTION_RATE_LIMITER?: import("@cloudflare/workers-types").DurableObjectNamespace;40 EXECUTION_RATE_LIMITER?: import("@cloudflare/workers-types").DurableObjectNamespace;
41 41
42 // Optional per-org hourly execution rate-limit override, parsed as an
43 // integer (defaults to EXECUTIONS_PER_ORG_PER_HOUR = 1000 when unset or
44 // unparseable). Exists for e2e: the production cap of 1000/hour can't be
45 // exercised with real executions, so the e2e dev-server env sets a small
46 // number to drive the backstop. Production leaves it unset.
47 EXECUTION_RATE_LIMIT_PER_HOUR?: string;
48
42 // Billing49 // Billing
43 AUTUMN_SECRET_KEY?: string;50 AUTUMN_SECRET_KEY?: string;
44 /** Optional Autumn base-URL override (Autumn emulator in tests/dev). */51 /** Optional Autumn base-URL override (Autumn emulator in tests/dev). */
e2e/setup/cloud.boot.ts+5−0
@@ -90,6 +90,11 @@ export const bootCloud = async (options: CloudBootOptions): Promise<CloudBooted> · 89 unmodified lines
90 MCP_AUTHKIT_DOMAIN: workosUrl,90 MCP_AUTHKIT_DOMAIN: workosUrl,
91 MCP_RESOURCE_ORIGIN: options.publicUrl,91 MCP_RESOURCE_ORIGIN: options.publicUrl,
92 ALLOW_LOCAL_NETWORK: "true",92 ALLOW_LOCAL_NETWORK: "true",
93 // Shrink the per-org hourly execution cap (prod default 1000) to a number
94 // the rate-limit-backstop scenario can actually exhaust with real
95 // executions. Reaches the worker via CLOUDFLARE_INCLUDE_PROCESS_ENV, same
96 // as ALLOW_LOCAL_NETWORK.
97 EXECUTION_RATE_LIMIT_PER_HOUR: "3",
93 // Throwaway PGlite on its own port + dir so it never fights `bun dev`.98 // Throwaway PGlite on its own port + dir so it never fights `bun dev`.
94 DEV_DB_PORT: String(options.dbPort),99 DEV_DB_PORT: String(options.dbPort),
95 DEV_DB_PATH: dbPath,100 DEV_DB_PATH: dbPath,