The issue requests relaxing cache restrictions during Draft Mode but involves core caching logic.
The issue requests allowing dynamic APIs like cookies() in cache scopes during Draft Mode, arguing cache is already bypassed. This requires modifying cache behavior validation while preserving Draft Mode's dynamic rendering guarantees. The main challenge is ensuring this change doesn't introduce caching edge cases or break existing Draft Mode assumptions.
https://github.com/angeloashmore/cache-components-draft-mode-dynamic-apis
cookies()cookies() and throwsCurrent behavior:
When Draft Mode is enabled and I try to call cookies() inside a "use cache" function, Next.js throws an error:
Error: Route / used `cookies()` inside "use cache". Accessing Dynamic data
sources inside a cache scope is not supported. If you need this data inside a
cached function use `cookies()` outside of the cached function and pass the
required dynamic data in as an argument. See more info here:
https://nextjs.org/docs/messages/next-request-in-use-cache
This error occurs even though Draft Mode is enabled, which means the cache is already being bypassed (as fixed in #76581 / PR #77141).
Expected behavior:
When Draft Mode is enabled, dynamic APIs like cookies() and headers() should be allowed inside "use cache" functions, since:
draftMode().isEnabled is already allowed — As noted in PR #73324, draftMode().isEnabled is permitted inside "use cache" because "when it's on, it switches everything to dynamic rendering anyway, so that prerender/cache entry is ignored." The same logic should apply to other dynamic APIs.Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 25.1.0: Mon O
Claim this issue to let others know you're working on it. You'll earn 10 points when you complete it!