AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

PPR Pages Lose Cache After `Next Start` Restart And RSC Payload Serves Stale Build-Time Data Due To Missing `.Rsc` File In File-System-Cache

File-system-cache `set()` omits the `.rsc` file for PPR routes, causing `get()` to treat the entry as missing after restart or eviction. This results in fallback shell re-rendering and stale RSC payloads for client navigation, leading to data inconsistency.

highConfidence 90%Next.jsAffected V16.4.0-Canary.63Affected V16.3.5Affected V16.3.8

Origin Analysis

In Next.js file-system-cache, the `set` method writes the `.rsc` file only under conditions that do not cover PPR routes upgraded from the fallback shell to a static page. When `postponed` becomes `null` at runtime, `value.rsc` is available but is skipped, so the `.rsc` is never persisted. On restart or eviction, `get()` finds `.html` but no `.rsc` and, because `postponed == null`, falls back to the shell or build-time data, causing the observed mismatch.
1. Clone repro repo. 2. Run `npm install`. 3. Run `./repro.sh` for restart scenario, or `PROBE_MEM=40000 ./repro.sh evict` for eviction scenario. 4. Observe fallback shell after restart/eviction and stale RSC payload on client navigation.

Fixing Code Block

Edge Case Audit

The added `.rsc` write increases disk I/O for every PPR cache set. The unlink operation may race with concurrent cache writes or eviction if multiple processes share the same cache directory (e.g., multiple Next.js instances on the same host). Ensure no simultaneous access to the same cache path or use a single-writer design. Rollback: revert this patch and clear the cache directory to avoid inconsistent state, but the original bug will recur.

Ecosystem Topology