Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Fetch cache isn't bypassed in draft mode

Closed Beginner friendly
#4,301 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@sharonadhitya is already working on this.

Since Oct 25, 2026.

  • #4318 by @james-elicx — merged

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

  1. Route handler or page in draft mode (draftMode().enable() cookie set).
  2. Render await fetch('https://example.com/data', { next: { revalidate: false } }).
  3. 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

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from cloudflare/vinext

All issues in cloudflare/vinext

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.