Skip to content

feat(cloudflare): scaffold Response Store Wrangler config - #3249

Merged
james-elicx merged 6 commits into
mainfrom
codex/response-store-wrangler-config
Sep 14, 2026
Merged

feat(cloudflare): scaffold Response Store Wrangler config#3249
james-elicx merged 6 commits into
mainfrom
codex/response-store-wrangler-config

Conversation

@james-elicx

@james-elicx james-elicx commented Sep 14, 2026

Copy link
Copy Markdown
Member

Summary

  • generate a collocated wrangler.response-store.jsonc when service-binding Response Store caching is selected
  • keep the application and Response Store Wrangler configs authoritative, editable, and independently deployable
  • point the service config directly at the installed @cloudflare/workers-response-store implementation
  • keep caching opt-in while defaulting to service-binding mode once Response Store is selected
  • preserve compatible user-owned names/resources and reject conflicting application bindings
  • deploy and test service-binding and self-contained modes explicitly in CI

Supersedes #3248 with a config-first design. vinext-cloudflare deploy only deploys the application; users deploy the collocated Response Store config independently.

Validation

  • 576 focused init/config/deploy tests
  • 44 Workers Response Store tests, including Wrangler dry-runs and both local modes
  • 30 Cloudflare adapter tests, including both deployed adapter modes
  • Knip, formatting, lint, type checks, actionlint, and git diff --check
  • exact-head CI: 76/76 checks passed, including live Response Store E2E, generated apps, preview deployments, smoke tests, browser E2E, and cleanup
  • independent exact-head review: clean after addressing all findings
  • Big Bonk: two initial findings fixed with regressions; bounded re-review was canceled after exceeding its explicit eight-minute limit

@pkg-pr-new

pkg-pr-new Bot commented Sep 14, 2026

Copy link
Copy Markdown

Open in StackBlitz

@vinext/cloudflare

npm i https://pkg.pr.new/cloudflare/vinext/@vinext/cloudflare@3249

create-vinext-app

npm i https://pkg.pr.new/cloudflare/vinext/create-vinext-app@3249

@vinext/types

npm i https://pkg.pr.new/cloudflare/vinext/@vinext/types@3249

vinext

npm i https://pkg.pr.new/cloudflare/vinext@3249

@cloudflare/workers-response-store

npm i https://pkg.pr.new/cloudflare/vinext/@cloudflare/workers-response-store@3249

commit: 4499f06

@github-actions

github-actions Bot commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Performance benchmarks

Compared 4499f06 against base 8eccc20 using alternating same-runner rounds. Next.js was unchanged and skipped.

0 improved · 0 regressed · 6 within ±1.5%

Scenario Framework Baseline Current Change
Client bundle size (gzip) vinext 142.2 KB 142.2 KB ⚫ +0.0%
Client entry size (gzip) vinext 129.6 KB 129.6 KB ⚫ 0.0%
Dev server cold start vinext 2.00 s 2.00 s ⚫ -0.1%
Production build time vinext 2.08 s 2.10 s ⚫ +0.8%
RSC entry closure size (gzip) vinext 125.8 KB 125.8 KB ⚫ +0.0%
Server bundle size (gzip) vinext 216.5 KB 216.5 KB ⚫ +0.0%

View detailed results and traces

🟢 improvement · 🔴 regression · ⚫ change below 1.5% · paired base/head

@github-actions

Copy link
Copy Markdown
Contributor
Example Preview Production Original
app-router-cloudflare preview production
pages-router-cloudflare preview production
app-router-playground preview production original
realworld-api-rest preview production
nextra-docs-template preview production
benchmarks preview production
hackernews preview production original
response-store-demo preview production
static-export preview production
web preview production

@james-elicx

Copy link
Copy Markdown
Member Author

/bigbonk review for issues. You have an 8 minute time limit.

Comment thread packages/vinext/src/init-cloudflare.ts Outdated
Comment thread packages/vinext/src/init-cloudflare.ts
@ask-bonk

ask-bonk Bot commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Submitted 2 actionable inline findings. tests/init-cloudflare.test.ts passes.

github run

@james-elicx

Copy link
Copy Markdown
Member Author

/bigbonk review for issues. Re-review head d1230b6 after the two Bonk comments were addressed. You have an 8 minute time limit.

if (
!isUnknownRecord(responseStoreConfig.cache) ||
responseStoreConfig.cache.enabled !== true ||
!isUnknownRecord(responseStoreExport) ||

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This accepts a ResponseStoreBinding export without verifying type: "worker". Wrangler’s WorkerEntrypointExport requires that discriminator, so the existing-config fixture in tests/init.test.ts passes init but the generated deployment config is schema-invalid. Validate responseStoreExport.type === "worker" here before treating the collocated config as deployable.

path.dirname(finalWranglerPath),
RESPONSE_STORE_WRANGLER_CONFIG,
);
if (!fs.existsSync(responseStorePath)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If the application already has a valid RESPONSE_STORE binding to an externally managed/shared Worker, readResponseStoreServiceName() reuses that service name and this block creates a new local config under the same name. The emitted next step then tells the user to deploy it, potentially replacing the shared Worker. Existing service bindings need to be treated as external (skip scaffolding) or rejected unless ownership can be established by an existing collocated config.

if (!expression) return;
const call = findPluginCall(config, vinextBinding);
const firstArgument = call?.arguments[0];
if (!call || !firstArgument || firstArgument.type === "SpreadElement") return;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Returning for a spread argument silently leaves setup half-applied. For vinext(...[options]), this function adds neither cache: responseStoreAdapter() nor an error, while the Wrangler config and adapter import are still updated. Match the other helpers and reject this non-static call shape so init cannot report success with Response Store disabled in Vite.

if (mode === "self-contained") {
output.appendLeft(call.end - 1, '{ mode: "self-contained" }');
}
} else if (argument.type === "ObjectExpression") {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Treating every object expression as statically updateable misses spreads and duplicate properties. With responseStoreAdapter({ ...options }) (or { mode: "service-binding", ...options }) and options.mode === "self-contained", selecting service-binding inserts no final explicit mode, so the adapter remains self-contained while Wrangler is converted to service-binding. Reject ambiguous properties or append the selected mode after them.

if (!isUnknownRecord(value)) {
throw new Error(`The existing Wrangler config has an invalid ${name} export.`);
}
if (value.cache === undefined) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This mutates every declarative export as though it were a Worker entrypoint. A valid existing export such as { type: "durable-object", storage: "sqlite" } gains an unsupported cache field, and the migration added below also conflicts with Wrangler’s rule that Durable Objects use either declarative exports or migrations, not both. Self-contained setup should preserve/reject declarative Durable Object exports rather than producing an undeployable config.

@ask-bonk

ask-bonk Bot commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

@james-elicx Bonk workflow was cancelled.

View workflow run · To retry, trigger Bonk again.

@james-elicx
james-elicx marked this pull request as ready for review September 14, 2026 16:51
@james-elicx
james-elicx merged commit 9d45b5b into main Sep 14, 2026
125 of 129 checks passed
@james-elicx
james-elicx deleted the codex/response-store-wrangler-config branch September 14, 2026 17:11
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