feat(cloudflare): scaffold Response Store Wrangler config - #3249
Conversation
@vinext/cloudflare
create-vinext-app
@vinext/types
vinext
@cloudflare/workers-response-store
commit: |
Performance benchmarksCompared 0 improved · 0 regressed · 6 within ±1.5%
View detailed results and traces 🟢 improvement · 🔴 regression · ⚫ change below 1.5% · paired base/head |
|
|
/bigbonk review for issues. You have an 8 minute time limit. |
|
Submitted 2 actionable inline findings. |
|
/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) || |
There was a problem hiding this comment.
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)) { |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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") { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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.
|
@james-elicx Bonk workflow was cancelled. View workflow run · To retry, trigger Bonk again. |
Summary
wrangler.response-store.jsoncwhen service-binding Response Store caching is selected@cloudflare/workers-response-storeimplementationSupersedes #3248 with a config-first design.
vinext-cloudflare deployonly deploys the application; users deploy the collocated Response Store config independently.Validation
git diff --check