Repository navigation
SMOODEV-4146: Keep APP_PAGE segmentData a Map in the S3 cache - #14
Merged
Merged
Conversation
Next 16 stores an APP_PAGE's per-segment prefetch payloads in a Map, and
JSON.stringify has no form for a Map — it was stored as {}. On a cache hit
Next calls cachedData.segmentData.get(...), which threw, so every client
segment prefetch (Next-Router-Segment-Prefetch) of an ISR/SSG page answered
500: smoo.ai's /, /help, /data-deletion and /privacy-policy, prefetched from
links all over the dashboard.
Maps now travel as { __map: entries } (their Buffers encoded as before), and an
entry written before this fix — segment payloads already lost — reads as a miss
so Next regenerates it instead of serving it. Release 0.2.3.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LbevoiGNpgJy6qTPvk4EVt
|
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.
Problem
Next 16 keeps an APP_PAGE's per-segment prefetch payloads in
segmentData: Map<string, Buffer>.JSON.stringifyhas no form for a Map, so the S3 cache handler stored it as{}. On a cache hit Next callscachedData.segmentData.get(segmentPrefetchHeader)(next/dist/build/templates/app-page.js), which throws — every client segment prefetch (Next-Router-Segment-Prefetch: /_tree) of an ISR/SSG page answers 500 with an empty body.On smoo.ai that's
/,/help,/data-deletion,/privacy-policy, prefetched from links across the dashboard. Found by the e2e route sweep (SMOODEV-4130); reproducible without auth:Solution
serializeencodes Maps as{ __map: [[k, v], …] }(the replacer recurses into the entries, so their Buffers are base64'd as before);deserializerebuilds the Map.{}) reads as a miss, so Next regenerates it rather than serving a broken entry — no S3 purge needed.Verification
{}entry → miss) failed before the fix, pass after; existing Buffer tests still pass (node --test src/next/cache-handler.test.cjs: 4/4).segmentData = new Map()ofsegmentPath → Buffer).Jira: https://smooai.atlassian.net/browse/SMOODEV-4146
🤖 Generated with Claude Code
https://claude.ai/code/session_01LbevoiGNpgJy6qTPvk4EVt