next.js
8e47c2ef - Fix draft mode rendering with Cache Components (#100728)

Commit
14 days ago
Fix draft mode rendering with Cache Components (#100728) PR #77141 made `'use cache'` bypass cache-handler reads and cache persistence when draft mode is enabled. Later changes, including #98005, made cached navigations reuse the static RDC. The additional postponed-state lookup for self-hosted RSC navigations and Server Actions did not check draft mode, so those renders could reuse published values. Draft mode HTML page loads already bypassed the response cache. Both document and navigation responses could still generate an embedded runtime prefetch with Partial Prefetching. Its final prerender expected RDC entries that draft mode deliberately did not save, which caused unexpected cache miss warnings. This change skips the additional postponed-state lookup for draft mode requests and disables cached-navigation rendering for their document and navigation responses. Server Actions that enable draft mode discard the published RDC before the subsequent render. Dedicated runtime-prefetch requests still use their existing renderer. PR #98533 proposes disabling client-initiated prefetches in draft mode. That work remains separate and may continue in a replacement PR. The tests cover fresh draft mode documents and navigations, actions that enable and disable draft mode, and form submissions without JavaScript. Fixes #100680 Closes #100685 Closes #100697
Author
Parents
Loading