Skip to content

LTRAC-1498: Bind CATALYST_ROUTES_KV namespace in Wrangler config - #3169

Draft
jorgemoya wants to merge 1 commit into
canaryfrom
jorgemoya/ltrac-1498-wrangler-routes-kv-binding
Draft

LTRAC-1498: Bind CATALYST_ROUTES_KV namespace in Wrangler config#3169
jorgemoya wants to merge 1 commit into
canaryfrom
jorgemoya/ltrac-1498-wrangler-routes-kv-binding

Conversation

@jorgemoya

Copy link
Copy Markdown
Contributor

Linear: LTRAC-1498
Parent: LTRAC-1019

What/Why?

On BigCommerce Native Hosting, proxies/with-routes currently has no shared cache — createKVAdapter finds neither Vercel Runtime Cache nor Upstash, so it falls back to MemoryKvAdapter, an in-process LRU that isn't shared across edge invocations. Every project is getting its own Cloudflare KV namespace to fix that; this PR is the CLI half, adding the CATALYST_ROUTES_KV binding to the generated Wrangler config so local dev matches what ships.

This file already carries a "keep in sync with Ignition's metadata.go" contract, and that comment is extended to cover the new binding — with one clarification worth reading, because it's the part most likely to be misunderstood: only the binding name is shared with Ignition. The namespace id here is a local-only placeholder; Ignition overwrites it with the real per-project namespace it provisioned when it uploads the Worker.

The placeholder is catalyst-routes-kv-local, and its shape is deliberate. A real Cloudflare namespace id is always a 32-character lowercase hex string, so this value cannot be mistaken for one. If this config were ever pointed at the live API, the request fails closed with an invalid-id error rather than silently reading or writing a real store's routing cache. Locally it's just a key prefix for Miniflare's simulated store under .wrangler/state/v3/kv, and the wrangler deploy --dry-run bundling step never resolves bindings against the API at all.

No vars entry is needed — isolation in this design is structural (a Worker can only reach namespaces bound to it), so there's no scope or secret value to inject.

The runtime adapter that actually reads this binding ships separately in LTRAC-1499. Until that lands, the binding is present and simply unread, which is harmless — and it means this PR can merge on its own without changing any runtime behaviour.

Testing

pnpm vitest run src/cli/lib/wrangler-config.spec.ts   # in packages/catalyst
✓ src/cli/lib/wrangler-config.spec.ts (6 tests)

Covers the binding being emitted with the expected name, and the placeholder id being distinguishable from a real Cloudflare namespace id.

To check by hand: run catalyst build on a project and inspect the generated core/.bigcommerce/wrangler.jsonc for the kv_namespaces entry, then catalyst start and confirm Miniflare creates the local store under core/.wrangler/state/v3/kv.

Migration

None. Purely additive to generated config — no existing files move, no breaking changes, and no action required from anyone rebasing. A patch changeset is included.

… config

Add a kv_namespaces entry for CATALYST_ROUTES_KV to the generated Wrangler
config so the routing cache in core's with-routes proxy has a shared store
on Native Hosting rather than falling back to a per-invocation memory cache.

The namespace id here is a local-only placeholder. The generated config only
drives `wrangler dev`/`catalyst start` and the `wrangler deploy --dry-run`
bundling step, neither of which resolves bindings against the Cloudflare API;
Ignition binds the real per-project namespace at upload time. The value is
deliberately not 32-char lowercase hex -- the only shape a provisioned
namespace id can take -- so a local build cannot reach a production store's
cache even by accident. It fails closed instead.

Also extends the "keep in sync with Ignition" header comment to cover the new
binding, and notes that only the binding *name* is shared across the two.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Aug 6, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: d948768

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@bigcommerce/catalyst Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel

vercel Bot commented Aug 6, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
catalyst Ready Ready Preview Aug 6, 2026 9:51pm

Request Review

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Bundle Size Report

Comparing against baseline from 7848623 (2026-08-06).

No bundle size changes detected.

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Unlighthouse Performance Comparison — Vercel

Comparing PR preview deployment Unlighthouse scores vs production Unlighthouse scores.

Summary Score

Aggregate score across all categories as reported by Unlighthouse.

Prod Desktop Prod Mobile Preview Desktop Preview Mobile
Score 89 93 92 94

Category Scores

Category Prod Desktop Prod Mobile Preview Desktop Preview Mobile
Performance 70 84 71 76
Accessibility 95 92 95 98
Best Practices 100 100 100 100
SEO 88 100 88 100

Core Web Vitals

Metric Prod Desktop Prod Mobile Preview Desktop Preview Mobile
LCP 5.5 s 4.5 s 4.8 s 6.7 s
CLS 0.039 0 0.037 0.011
FCP 1.2 s 1.5 s 1.2 s 1.3 s
TBT 0 ms 0 ms 10 ms 0 ms
Max Potential FID 40 ms 50 ms 50 ms 50 ms
Time to Interactive 5.5 s 4.5 s 6.2 s 6.7 s

Full Unlighthouse report →

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