mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 00:09:23 +02:00
[PR #1092] fix(cache): scope use cache keys by deployment id #1089
Labels
No labels
enhancement
enhancement
good first issue
help wanted
nextjs-tracking
nextjs-tracking
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/vinext#1089
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/cloudflare/vinext/pull/1092
Author: @NathanDrake2406
Created: 5/6/2026
Status: 🔄 Open
Base:
main← Head:nathan/use-cache-deployment-id📝 Commits (6)
20cb09dfix(cache): scope use cache keys by deployment id60c8ebffix(config): resolve deployment id for cache seeds518b83erefactor(cache): carry deployment id through request contextc3cf95crefactor(cache): reuse request context for deployment id1c7d459Merge remote-tracking branch 'upstream/main' into nathan/use-cache-deployment-id6c3bd8ctest(app-elements): expect artifact compatibility metadata📊 Changes
12 files changed (+420 additions, -61 deletions)
View changed files
📝
packages/vinext/src/config/next-config.ts(+28 -0)📝
packages/vinext/src/deploy.ts(+9 -0)📝
packages/vinext/src/global.d.ts(+6 -0)📝
packages/vinext/src/index.ts(+5 -0)📝
packages/vinext/src/server/app-router-entry.ts(+97 -52)📝
packages/vinext/src/server/app-rsc-handler.ts(+10 -0)📝
packages/vinext/src/shims/cache-runtime.ts(+24 -9)📝
packages/vinext/src/shims/unified-request-context.ts(+15 -0)📝
tests/app-elements.test.ts(+1 -0)📝
tests/deploy.test.ts(+11 -0)📝
tests/next-config.test.ts(+57 -0)📝
tests/shims.test.ts(+157 -0)📄 Description
What this changes
Shared
"use cache"entries now include a deployment-aware seed before falling back to the existing vinext build ID. This matches the upstream cache key precedence model for vinext's supported deployment ID sources while keeping Worker deployment identity request-scoped.Why
Next.js changed
use-cache-wrapperso cache keys useworkStore.deploymentId || workStore.buildId. Without this, two deployments can share the same"use cache"entry when the build ID is stable or when a runtime deployment ID changes independently of the build fallback.References:
deploymentIdconfig docs: next.config.js deploymentIdApproach
cache-runtime, with precedence: request-scoped deployment ID, explicit startup/test fallback, build-time resolved deployment ID, then vinext build ID.next.config.js deploymentIdbeforeNEXT_DEPLOYMENT_ID, validate its string shape, and expose the resolved value throughprocess.env.__VINEXT_DEPLOYMENT_ID.env.NEXT_DEPLOYMENT_IDorenv.CF_VERSION_METADATA.idin the App Router Worker entry.version_metadatabinding inwrangler.jsoncso deployed Cloudflare Workers haveCF_VERSION_METADATA.idavailable by default.Validation
vp test run tests/shims.test.ts -t 'use cache'vp test run tests/deploy.test.ts -t 'Wrangler Config Generation|generateAppRouterWorkerEntry'vp test run tests/next-config.test.ts -t 'deploymentId|generateBuildId'vp check packages/vinext/src/config/next-config.ts packages/vinext/src/shims/cache-runtime.ts packages/vinext/src/server/app-router-entry.ts packages/vinext/src/deploy.ts packages/vinext/src/index.ts packages/vinext/src/global.d.ts tests/shims.test.ts tests/deploy.test.ts tests/next-config.test.tsvp check --fixandknip --no-progressRisks / follow-ups
This PR scopes the App Router Worker entry and generated deploy config. Custom Worker entries that bypass
vinext/server/app-router-entrystill need to provide their own deployment context if they invoke lower-level internals directly.★ Insight
"use cache"with deployment identity before build identity because cacheHandlers can outlive a single build assumption.envstate, so reading it at module registration would miss or race the real deployment value.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.