Instant validation for caches excluded from prerenders - #98342
Open
lubieowoce wants to merge 3 commits into
Open
Instant validation for caches excluded from prerenders#98342lubieowoce wants to merge 3 commits into
lubieowoce wants to merge 3 commits into
Conversation
Contributor
Failing CI jobsCommit: a29a48f | About building and testing Next.js |
lubieowoce
force-pushed
the
lubieowoce/instant-validation-excluded-caches
branch
2 times, most recently
from
September 8, 2026 04:48
7370b52 to
332b4d9
Compare
lubieowoce
marked this pull request as ready for review
September 8, 2026 04:53
unstubbable
approved these changes
Sep 8, 2026
lubieowoce
force-pushed
the
lubieowoce/instant-validation-excluded-caches
branch
from
September 8, 2026 11:34
332b4d9 to
8bdee62
Compare
… instant validation
This also includes fixes around `RequestStore.hasIncompatibleShellContent`, which would be `false` if the render had a cache miss for a cache with `stale < MIN_SHELL_STALE`. We only track this when the cache is a hit and we know its cache life, so misses would hide it.
lubieowoce
force-pushed
the
lubieowoce/instant-validation-excluded-caches
branch
from
September 8, 2026 11:52
8bdee62 to
a29a48f
Compare
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.
Follow-up to #98339. Turns out we were not testing how caches excluded from static/runtime prerenders and app shells behave in Instant Validation, and it was somewhat broken. This PR adds test coverage and fixes some bugs I found along the way.
Fixes
use-cache-wrapperwas incorrectly gating cache delays in "request" stores onNODE_ENV === "development", which does not include build-time instant validation. The correct check is now implemented inisValidationRenderuse-cache-wrapperhas divergent behavior for caches withstale < MIN_SHELL_STALEacross app shells and PPR/static shells, which needs to be tracked so that we know that the same render can't be used for both Instant and Static Shell validation. When we see a cache entry like that, we now calltrackIncompatibleShellContent()LAZY_FULL_RENDERfor both. Cache misses now result in atrackIncompatibleShellContent()call to avoid thisTests
We now have tests for:
stale < MIN_SHELL_STALE- excluded from app shells, but included in static and runtime prefetchesstale < MIN_PREFETCHABLE_STALE- excluded from all prerendersexpire < MIN_PRERENDERABLE_EXPIRE- excluded from static prerenders, but allowed in runtime prerendersDue to bugs mentioned above, some of the added tests were failing before the fixes (mostly the ones that expect an error -- passing a "no validation errors" test is easy, just don't create any dynamic holes)
In build, these tests incorrectly reported no errors when they should've failed IV:
invalid - unguarded non-prefetchable cache (with short stale)(both PPF and non-PPF)non-app shell validation > invalid - unguarded non-prerenderable cache with short expirein build:app shell validation > invalid - unguarded cache with a shorter-than-shell staleTimein build:This is because we were missing cache delays in build-time instant validation (now fixed with
isValidationRender), so the caches weren't dynamic holes at all.The
stale < MIN_SHELL_STALEtests (app shell validation > invalid - unguarded cache with a shorter-than-shell staleTime) were also failing in dev:await nonShellCache()in the Runtime stage. But the initial render did not track incompatible data, so we incorrectly re-used it for SSV and IV. The cache was resolved inRuntimeso SSV saw a runtime hole andawait nonShellCache()errored in SSV withNext.js encountered runtime data during prerendering.await nonShellCache()inPrefetchStatic. We had no cache misses and did not track incompatible data, so we incorrectly re-used the main non-runtime-shell render for SSV and IV. The cache resolved inPrefetchStaticand it wasn't a hole inShellRuntimeso no error was reported.