[test] Add failing tests for stale route handler and page cached data#96021
Merged
unstubbable merged 1 commit intoJul 22, 2026
Merged
Conversation
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`.
Contributor
Tests PassedCommit: 1e76766 |
Contributor
Stats from current PR🔴 1 regression, 1 improvement
📊 All Metrics📖 Metrics GlossaryDev Server Metrics:
Build Metrics:
Change Thresholds:
⚡ Dev Server
📦 Dev Server (Webpack) (Legacy)📦 Dev Server (Webpack)
⚡ Production Builds
📦 Production Builds (Webpack) (Legacy)📦 Production Builds (Webpack)
📦 Bundle SizesBundle Sizes⚡ TurbopackClient Main Bundles
Server Middleware
Build DetailsBuild Manifests
📦 WebpackClient Main Bundles
Polyfills
Pages
Server Edge SSR
Middleware
Build DetailsBuild Manifests
Build Cache
🔄 Shared (bundler-independent)Runtimes
📝 Changed Files (6 files)Files with changes:
View diffsapp-page-exp..ntime.dev.jsDiff too large to display app-page-tur..ntime.dev.jsDiff too large to display app-page-tur..ntime.dev.jsDiff too large to display app-page.runtime.dev.jsDiff too large to display pages-api.ru..time.prod.jsDiff too large to display pages.runtime.prod.jsDiff too large to display 📎 Tarball URLCommit: 1e76766 |
unstubbable
marked this pull request as ready for review
July 21, 2026 22:11
gaojude
approved these changes
Jul 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In dev, editing a file does not evict existing
use cacheentries; 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 itsuse cachekey 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/cachedfetched throughnext.fetch, and a page atapp/cached-pagerendered throughnext.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 outsideuse cache), then asserts the cached value reflects the edit. Both are markedit.failingbecause 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
Stack created with GitHub Stacks CLI • Give Feedback 💬