Fetch cache isn't bypassed in draft mode
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 75/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- next.js, react, typescript, vite
- Domain
- web-dev
Research direction
Read dist/shims/cache-runtime.js to see how isDraftModeEnabled() gates 'use cache'. Then add the same draft-mode check in dist/shims/fetch-cache.js so cacheable fetches act like cache: 'no-store' in draft mode. Done when a draft-mode request fetches fresh responses instead of year-long cached ones.
Written by the indexing model from the issue text.
Description
Next.js skips the fetch cache when draft mode is on. vinext skips 'use cache' in draft mode (dist/shims/cache-runtime.js: if (isDev || isDraftModeEnabled())), but dist/shims/fetch-cache.js has no draft-mode check. A fetch(url, { next: { revalidate: false, tags } }) is stored for a year and then served to draft-mode requests.
Impact
next-sanity's <SanityLive> relies on Next's behaviour. In draft mode it only calls router.refresh(); its server action says so:
cache is bypassed in draft mode so the router.refresh() function is called instead of revalidating tags
Under vinext the refresh re-renders the same cached query responses, so edits in Sanity's Presentation tool never show in the preview. (We hit this through next-sanity's react-server build, which issues revalidate: false fetches; see also #4302, the missing next-js condition.)
Repro
- Route handler or page in draft mode (
draftMode().enable()cookie set). - Render
await fetch('https://example.com/data', { next: { revalidate: false } }). - Change the upstream response and refresh.
- Next.js: fresh response in draft mode.
- vinext: the cached response, for up to a year.
Expected
In draft mode, cacheable fetches behave like cache: 'no-store', matching Next.js and vinext's own 'use cache' handling.
Environment: vinext 1.3.0, @vinext/cloudflare 1.2.0, @cloudflare/vite-plugin 2.0.0-beta.v.4, vite 8.3.0, @vitejs/plugin-rsc 0.5.38, next 16.4.2, react 19.3.1. App Router with Cache Components, deployed with cloudflare.config.ts.
- Dominant language
- TypeScript
- Stars
- 9.3k
- Forks
- 461
- Avg merge
- 1d 48m
- Merged PRs (30d)
- 501
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from cloudflare/vinext
-
The `next-js` export condition isn't set, so packages like next-sanity load their non-Next buildPossibly taken @james-elicx claimed this 2 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
cloudflare/vinext#4302 · 1 comment ·
Maintainers usually reply within 1 day
-
[nextjs-tracker] Fix navigation from global-not-found to app routesPossibly taken @kanchingyg claimed this 3 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
cloudflare/vinext#4233 ·
Maintainers usually reply within 1 day
-
nextjs-tracking
Difficulty 2/5 1-3 hours Newbie friendliness 69/100
cloudflare/vinext#3920 ·
Maintainers usually reply within 1 day
-
docs: document deployment with Cloudflare Workers Builds / Git integrationPossibly taken @reginaldalfret claimed this 21 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
cloudflare/vinext#3738 ·
Maintainers usually reply within 1 day
-
Standalone server.js does not default NODE_ENV to productionPossibly taken @reginaldalfret claimed this 33 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
cloudflare/vinext#3444 ·
Maintainers usually reply within 1 day
All issues in cloudflare/vinext
Similar issues
-
[Bug]: Pen taps on sidebar rows start a drag and lose their clickPossibly taken @makhnatkin claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
b310-digital/teammapper#1515 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
puckeditor/puck#1884 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
outline/outline#14378 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
nicobailon/pi-web-access#642 ·
Maintainers usually reply within 1 day