mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #339] [MERGED] fix: unstable_cache undefined cache #492
Labels
No labels
enhancement
enhancement
good first issue
help wanted
nextjs-tracking
nextjs-tracking
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/vinext#492
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/cloudflare/vinext/pull/339
Author: @JaredStowell
Created: 3/8/2026
Status: ✅ Merged
Merged: 3/8/2026
Merged by: @james-elicx
Base:
main← Head:jstowell/fix-undefined-caching📝 Commits (1)
a77cbf4Fix unstable_cache undefined cache📊 Changes
2 files changed (+38 additions, -2 deletions)
View changed files
📝
packages/vinext/src/shims/cache.ts(+17 -2)📝
tests/shims.test.ts(+21 -0)📄 Description
Summary
Fix
unstable_cache()so cached functions that return top-levelundefinedactually hit the cache on subsequent calls.Problem
unstable_cache()was serializing results withJSON.stringify(result)and reading them back withJSON.parse(body).For a top-level
undefinedreturn value,JSON.stringify(undefined)returnsundefinedrather than a JSON string. On the next read,JSON.parse(undefined)throws, so the shim treated the entry as invalid and recomputed the function every time.Changes
undefinedresults in theunstable_cache()serialization pathJSON.parseunstable_cache()-wrapped function that returnsundefinedand should only execute once across repeated callsWhy
This is a real correctness/performance bug in the cache shim: callers still receive
undefined, but the cache never produces a true hit for that value.Testing
pnpm test tests/shims.test.ts -t "unstable_cache"🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.