Skip to content

fix(cloudflare): give Catalog and commerce-customer-context a measured CPU budget - #1032

Merged
BleedingDev merged 1 commit into
mainfrom
fix/cloudflare-readiness-limits
Sep 30, 2026
Merged

BleedingDev merged 1 commit into
mainfrom
fix/cloudflare-readiness-limits

Conversation

@BleedingDev

Copy link
Copy Markdown
Contributor

Why the change

Most requests to the stage Catalog and commerce-customer-context Workers die with Cloudflare error 1102 because they need far more CPU than the 100 ms vertical cap, and this gives those two Workers a cap based on what stage analytics actually measured.

Special things to note

  • Root cause: each BFF request builds and disposes the whole Effect HTTP API runtime (workerd won't let I/O objects cross requests), so CPU grows with endpoint count. Catalog has ~200 endpoints and commerce-customer-context ~115; the next biggest vertical has ~20. wrangler tail shows every 1102 as exceededCpu, killed at 100 ms when warm and at ~2100 ms when cold.
  • Stage analytics, last 72 h: the largest successful requests used 1590 ms (Catalog) and 2015 ms (commerce-customer-context), and requests that got cut off had already used up to 2539 ms. 3000 ms is the smallest round cap above all of those. Every other vertical keeps 100 ms and the Shell keeps 200 ms.
  • The account CPU allowance and the hourly stage cost guard stay the same. The cap only limits one runaway request.

Change outline

CPU budgets

-CLOUDFLARE_WORKER_CPU_MS = { shell: 200, vertical: 100 }
+CLOUDFLARE_WORKER_CPU_MS = { largeApiVertical: 3000, shell: 200, vertical: 100 }

How each Worker picks its budget

 createModernConfig({ ..., cloudflareCpuMs = vertical })
-  createCloudflareDeployment(build, { name, unitServiceBindings })   // always vertical
+  createCloudflareDeployment(build, { cpuMs, name, unitServiceBindings })

 commerce-customer-context/modern.config.ts
+  cloudflareCpuMs: largeApiVertical
 catalog/modern.config.ts
-  createCloudflareWorkerConfig(env, { cpuMs: vertical, ... })
+  createCloudflareWorkerConfig(env, { cpuMs: largeApiVertical, ... })

Generated wrangler.json

 app-catalog                    limits: { cpu_ms: 100 → 3000 }
 app-commerce-customer-context  limits: { cpu_ms: 100 → 3000 }
 every other app-* Worker       limits unchanged

…d CPU budget

Every BFF request builds and disposes the whole Effect HTTP API runtime, so
its CPU grows with the endpoint count. The 100 ms vertical cap cut off most
requests to the two verticals with 200 and 115 endpoints (Cloudflare 1102).
Stage analytics peaked at 2015 ms for successful requests and 2539 ms for the
ones cut off, so they get a 3000 ms cap; every other vertical keeps 100 ms.
@semanticdiff-com

semanticdiff-com Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Review changes with  SemanticDiff

Changed Files
File Status
  app/packages/shared-contracts/tooling/modern-config.ts  45% smaller
  app/docs/architecture/DEPLOYMENT.md Unsupported file format
  app/scripts/tests/cloudflare-data-plane-bindings.test.mts  0% smaller
  app/verticals/catalog/modern.config.ts  0% smaller
  app/verticals/commerce-customer-context/modern.config.ts  0% smaller

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Sep 30, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 49 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 4daf7f35-10a4-470b-adf2-3443b97a32f3

📥 Commits

Reviewing files that changed from the base of the PR and between 42d9606 and e237fd5.

📒 Files selected for processing (5)
  • app/docs/architecture/DEPLOYMENT.md
  • app/packages/shared-contracts/tooling/modern-config.ts
  • app/scripts/tests/cloudflare-data-plane-bindings.test.mts
  • app/verticals/catalog/modern.config.ts
  • app/verticals/commerce-customer-context/modern.config.ts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@BleedingDev
BleedingDev merged commit bfd612c into main Sep 30, 2026
21 checks passed
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