Repository navigation
fix(use-cache): do not warn unexpected cache miss in draft mode (#100680) - #100697
Draft
wasim-builds wants to merge 1 commit into
Draft
wasim-builds wants to merge 1 commit into
wasim-builds wants to merge 1 commit into
Conversation
This branch has not been deployed
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?
Prevents logging
UnexpectedCacheMissError("Unexpected cache miss after cache warming phase during prerendering") when draft mode is enabled. Also ensuresLockfile.tryAcquiresafely handles native SWC bindings that return the native lockfile directly.Why?
When draft mode is active on a route using Partial Prefetching and Cache Components (
cacheComponents: true/ PPR),saveToResumeDataCacheinuse-cache-wrapper.tsdeliberately skips saving entries to the Resume Data Cache:During the subsequent prerender pass (
workUnitStore.type === 'prerender-runtime',!cacheSignal), the cache lookup inresumeDataCachenaturally misses because it was intentionally omitted in the warming phase.use-cache-wrapper.tsthen loggedUnexpectedCacheMissErrorassuming the cache miss was caused by non-deterministic arguments, producing false warning noise for every CMS preview and draft mode request (issue #100680).How?
packages/next/src/server/use-cache/use-cache-wrapper.ts, guard theconsole.warn(new UnexpectedCacheMissError(workStore.route))call withif (!workStore.isDraftMode). The hanging promise continues to be returned so the function becomes a dynamic hole evaluated during the dynamic rendering pass.packages/next/src/build/lockfile.ts, normalizebindings.lockfileTryAcquireSyncoutput so both the new structuredLockfileResultand pre-compiled native bindings returning raw external lockfiles are handled without throwingTypeError: Cannot read properties of null (reading 'type').test/production/app-dir/use-cache-non-deterministic-argsverifying that requests with draft mode enabled resolve cached values without logging cache miss warnings.Fixes #100680