Skip to content

feat(config): add worker.limits.cpu_ms per-project CPU limit - #299

Merged
Brooooooklyn merged 3 commits into
mainfrom
feat/worker-limits-cpu-ms
Aug 29, 2026
Merged

Brooooooklyn merged 3 commits into
mainfrom
feat/worker-limits-cpu-ms

Conversation

@Brooooooklyn

@Brooooooklyn Brooooooklyn commented Aug 27, 2026 •

Copy link
Copy Markdown
Member

What

Adds worker.limits.cpu_ms to void.json so a project can set its own Workers CPU cap per request.

{
  "worker": {
    "limits": { "cpu_ms": 30000 }
  }
}

Context: platform plans cap Workers-for-Platforms cpuMs (pro = 50 ms today). WASM workloads such as image generation need more. This gives the project a knob, and the platform clamps it to a per-plan ceiling (platform PR follows).

Changes

  • config.ts + schema.json: worker.limits validated as a strict object (unknown keys rejected), cpu_ms an integer in 1..300000 (Cloudflare's hard maximum)
  • Deploy manifest: optional additive limits: { cpuMs } field; manifest version stays 3, so old CLI / old API pairs keep working
  • Emitted by buildVoidManifest and buildFrameworkManifest; static manifests never carry limits
  • The value is also copied into the Cloudflare vite-plugin worker config, so the generated dist/ssr/wrangler.json enforces it on void deploy --backend cloudflare (found by adversarial review: without this the knob silently no-ops on the self-hosted path)
  • Docs: reference/config.md documents both paths; on the managed platform, a deploy above the plan ceiling rejects with 400, and only rollback clamps

Tests

  • config.test.ts: validation cases plus a schema-drift pin asserting schema.json bounds match runtime validation
  • package.test.ts: manifest emission for all three builders
  • plugin-dev-asset-routing.test.ts: the merged Cloudflare worker config carries limits.cpu_ms when configured, and no limits key otherwise
  • Full packages/void suite: 199 files passed, 3700 tests passed, 14 skipped (pre-existing gated live e2e)

🤖 Generated with Claude Code

https://claude.ai/code/session_01DF8p6MCmgiE7e3LM1J8EQV


Note

Medium Risk
Changes how deploy manifests and generated wrangler config express per-request CPU limits, which can affect runtime behavior and plan/account enforcement on production deploys, though values are strictly bounded and the manifest field is additive.

Overview
Projects can now set Workers CPU time per request via void.json under worker.limits.cpu_ms (integer 1–300000 ms), with strict validation, JSON schema support, and docs for managed vs self-hosted behavior.

The value flows into managed deploy manifests as optional limits.cpuMs (void and framework packaging paths; static manifests omit it) and into the generated Cloudflare worker config / dist/ssr/wrangler.json for void deploy --backend cloudflare and direct wrangler deploys. Deploy CLI passes the setting from config into both packaging flows.

Tests cover config validation, schema drift, manifest emission, and plugin worker config merging.

Reviewed by Cursor Bugbot for commit 59902dd. Bugbot is set up for automated code reviews on this repo. Configure here.

Adds a curated wrangler field to void.json so a project can set its own
Workers CPU cap:

- config.ts / schema.json: validate worker.limits as a strict object
  (unknown keys rejected) with cpu_ms an integer in 1..300000
- deploy manifest: carry limits.cpuMs (manifest version stays 3, the
  field is optional and additive)
- emit limits into buildVoidManifest and buildFrameworkManifest; static
  manifests never carry limits
- also copy the value into the Cloudflare vite-plugin worker config so
  the generated dist/ssr/wrangler.json enforces it on
  `void deploy --backend cloudflare` (adversarial-review finding)
- docs: reference/config.md documents managed-platform semantics
  (deploys above the plan ceiling reject; only rollback clamps) and the
  self-hosted passthrough

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DF8p6MCmgiE7e3LM1J8EQV
@Brooooooklyn
Brooooooklyn force-pushed the feat/worker-limits-cpu-ms branch from fc361a5 to c752d86 Compare August 28, 2026 16:02

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c752d8694c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread docs/reference/config.md Outdated
Brooooooklyn and others added 2 commits August 29, 2026 00:16
"No plan ceiling applies" on the self-hosted path was too broad. The
Void plan ceiling is bypassed there, but the Cloudflare account's own
CPU-time allowance still applies — Workers Free caps CPU at 10 ms per
request whatever `cpu_ms` says, so a value this page called
unrestricted could be constrained or rejected by Cloudflare.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Grrh3fMQxnc3MKfJWKg7Vv
Rollback clamps an over-ceiling value, but deploy rejects it. So a plan
downgrade leaves a project whose stored cpu_ms is now too high unable to
deploy at all until the value is lowered in void.json. Rejecting is the
intended behavior — explicit config that exceeds the plan should fail
loudly — but the consequence was undocumented.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Grrh3fMQxnc3MKfJWKg7Vv
@Brooooooklyn
Brooooooklyn merged commit 984fffe into main Aug 29, 2026
9 checks passed
@Brooooooklyn
Brooooooklyn deleted the feat/worker-limits-cpu-ms branch August 29, 2026 05:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant