Repository navigation
fix(seed): write routes under the key the runtime actually looks up - #21
Merged
Merged
Conversation
Two independent problems made seeded routes unreadable. Next.js 16.3.8+ scopes response-cache keys by source route (/route-cache/<KIND>/<hash>/$/<path>) and never asks a custom cache handler for a bare pathname. The build records the exact key in each artifact's .meta (routeCache.key). App Router and Pages Router routes are now seeded under that key when it is present. Before 16.3.8, routes are stored and looked up under Next's normalized page path, where / is /index. The seed wrote the root route under /, so it was never read, and read /index-prefixed routes from the wrong files. The artifact path and the fallback key now follow normalizePagePath. No option is needed for either case. Closes #16 Co-authored-by: jeroendegloire <13023723+jeroendegloire@users.noreply.github.com>
Merged
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.
Closes #16. Supersedes #18.
Two independent problems made seeded routes unreadable.
1. Next.js 16.3.8+: route-scoped keys (#16)
From 16.3.8, response-cache keys are scoped by source route (
/route-cache/<KIND>/<hash>/$/<path>) and a custom cache handler is never asked for a bare pathname. Seeds written under the pathname were never read, so the first request after a deploy was still aMISS.The build records the exact key in each artifact's
.meta(routeCache.key). App Router and Pages Router routes are now seeded under that key whenever it is present. This is automatic: when the key is in the build output, it is the only key that runtime will read, so there is nothing to opt into.2. Next.js < 16.3.8: root route key
Older versions look routes up under
normalizePagePath, where/is/index. The seed wrote the root route under/, so the home page seed was never read. Routes starting with/indexwere also read from the wrong artifact files. The artifact path and the fallback key now follow the same normalization.Verification
Unit: 190 passed (new cases fail on current main).
End to end, real Redis,
next build→seed→next start→ first request://blog/a(SSG)/legacy(Pages)Known limit: a page literally located at
/index(app/index/page.tsx) is still not served from a seed. On 16.3.8+ the key recorded in its build.metadiffers from the key the runtime requests for that URL, and before 16.3.8 Next resolves that URL to the root entry. Both happen inside Next and are unrelated to seeding.Thanks to @jeroendegloire for the report and the original patch in #18.