fix(cache): bypass fetch cache in draft mode - #2786
Conversation
Draft renders currently read and write shared fetch entries, so a fetch with next.revalidate can return published data to editors and publish draft data to later public requests.\n\nForward draft-mode fetches directly to the original fetch, matching Next.js and keeping draft responses out of the shared cache. Add regression coverage for both the cache read and write paths.
|
@codex review |
commit: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f54443eaed
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Performance benchmarksCompared 0 improved · 0 regressed · 6 within ±1.5%
View detailed results and traces 🟢 improvement · 🔴 regression · ⚫ change below 1.5% · paired base/head |
Pages Router preview requests now publish their decoded preview state to the unified request context in both development and production. Draft fetches continue through request-scoped deduplication while bypassing the shared data cache, with production and dev regressions covering both behaviors.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 966e89ade7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Build dedupe keys from effective GET and HEAD requests so Request init overrides cannot share a response across variants, while preserving body-bearing pass-through behavior. Record draft fetches as dynamic layout dependencies so App Router reuse cannot skip fresh data. Add regressions for both review findings.
|
@codex review |
|
Codex Review: Didn't find any major issues. Delightful! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Overview
Fix draft-mode data isolation for both App Router and Pages Router fetches. Draft renders now bypass persistent fetch-cache reads and writes while retaining render-scoped memoization, so editors receive current origin data without changing published cache entries.
What changed
createPatchedFetch.dedupeFetchso repeated GET and HEAD requests remain memoized within a render.initheader overrides cannot share a response across variants.Behavior
Validation
vp test run tests/fetch-cache.test.ts: 129 passedvp test run tests/pages-page-handler.test.ts: 37 passedvp test run tests/pages-router.test.ts: 378 passedvp test run tests/shims.test.ts: 1,278 passedvp check: 1,175 files checked with no warnings or errorsvp run vinext#build: passedReferences