Add e2e test for stale use cache content served to cookieless requests in dev#95931
Draft
gaojude wants to merge 1 commit into
Draft
Add e2e test for stale use cache content served to cookieless requests in dev#95931gaojude wants to merge 1 commit into
gaojude wants to merge 1 commit into
Conversation
Contributor
Stats from current PR🔴 3 regressions
📊 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
📎 Tarball URLCommit: 6a7cc71 |
Contributor
Failing test suitesCommit: 6a7cc71 | About building and testing Next.js
Expand output● hmr-deleted-page › should not show errors for a deleted page
Expand output● app dir - navigation › hash-with-scroll-offset › should scroll to the specified hash |
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.
What?
Adds a fourth dev-mode case to the
use-cache-deve2e suite. It proves thatnext devkeeps serving pre-edituse cachecontent to requests that carry no HMR refresh hash cookie, and that a hard reload is what repairs the entry.Why?
In dev, editing a file does not evict existing
use cacheentries. Invalidation works by re-keying: the HMR client stores each server component change hash in a__next_hmr_refresh_hash__cookie, and requests that carry the cookie use a new cache key. A client without the cookie (curl, a fresh browser profile, any plain HTTP request) keeps reading the old entry until it expires.The suite covers the browser side of this (HMR updates, soft reload, hard reload) but had no coverage for what a cookieless client sees after an edit. That gap is easy to mistake for a bug: compilation is clean and the connected browser shows the edit, yet
curl http://localhost:3000/still returns the old HTML.How?
The test drives the scenario with plain HTTP requests against the existing fixture, whose cached page renders the string
foo:fooand creates the cache entry keyed without an HMR refresh hash.next.patchFilereplacesfoowithbazinapp/page.tsx.cookie: __next_hmr_refresh_hash__=<random>rendersbazonce compilation finishes. Each retry attempt uses a fresh random value; a fixed value would cache a pre-edit render under that key on the first attempt and never converge. This request is also the compile barrier, so the next assertion cannot race.foo. This is the staleness claim: the edit did not evict the cookieless entry.Cache-Control: no-cache(what a browser hard reload sends) rendersbazand writes the fresh result back.baz. The entry is repaired for every client from here on.After the patch auto-reverts, one more
Cache-Control: no-cacherequest re-syncs the entry tofooso later tests in the suite start from a clean state.Passes with both
pnpm test-dev-turboandpnpm test-dev-webpack. The existingshould successfully finish compilation when "use cache" directive is added/removedcase fails on my machine on unmodified canary as well, so that failure is unrelated to this change.