next.js
70f8b678 - [test] Add failing tests for stale route handler and page cached data (#96021)

Commit
27 days ago
[test] Add failing tests for stale route handler and page cached data (#96021) In dev, editing a file does not evict existing `use cache` entries; an entry is invalidated only by re-keying, which today is driven by the `__next_hmr_refresh_hash__` cookie that the browser HMR client sets after each server-component change. A client that fetches directly (curl, a plain fetch, a second device) never sends that cookie, so its `use cache` key does not change across an edit and the stale entry keeps being served even after the module recompiles. This affects both route handlers and pages. This adds two e2e tests, each with its own fixture: a route handler at `app/api/cached` fetched through `next.fetch`, and a page at `app/cached-page` rendered through `next.render$`. Both paths bypass the browser HMR client, so neither request carries the cookie. Each test edits its source, waits for the module to recompile (observed through a literal read outside `use cache`), then asserts the cached value reflects the edit. Both are marked `it.failing` because the gap is not yet fixed. They run in dev only and fail in both Turbopack and webpack. A follow-up change sources the HMR refresh hash on the server rather than via the client cookie, so the cache is invalidated for every client regardless of how it fetches. Because route handlers and pages build their request stores through different paths, covering both here guards each one; that change will flip these tests to regular `it`. closes #95931 --- <sub>Stack created with <a href="https://github.com/github/gh-stack">GitHub Stacks CLI</a> • <a href="https://gh.io/stacks-feedback">Give Feedback 💬</a></sub>
Author
Parents
Loading