mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #294] [MERGED] Fix unstable_cache serving stale entries and incorrect revalidate default #452
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#452
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/294
Author: @southpolesteve
Created: 3/6/2026
Status: ✅ Merged
Merged: 3/6/2026
Merged by: @southpolesteve
Base:
main← Head:fix/unstable-cache-staleness-and-revalidate📝 Commits (2)
872c2f6Fix unstable_cache serving stale entries and incorrect revalidate default1eb8249Update IncrementalCacheValue.revalidate type in next-shims.d.ts📊 Changes
3 files changed (+89 additions, -5 deletions)
View changed files
📝
packages/vinext/src/shims/cache.ts(+9 -4)📝
packages/vinext/src/shims/next-shims.d.ts(+1 -1)📝
tests/shims.test.ts(+79 -0)📄 Description
Summary
unstable_cachewas not checkingcacheStatewhen reading from the cache, so time-expired entries were served forever instead of triggering a re-fetch. Added acacheState !== "stale"check to match the pattern used in the"use cache"runtime.revalidate: When norevalidateoption was provided, the cached entry was stored withrevalidate: 0. This is semantically wrong since0means "revalidate immediately" in Next.js cache semantics. Changed the default tofalse, which means "cache indefinitely" (no time-based expiry), matching Next.js behavior forunstable_cachewithout an explicit revalidate.CachedFetchValue.revalidatetype fromnumbertonumber | falseto reflect the valid states.Tests
Added 2 new tests:
unstable_cache re-fetches when entry is stale (time-expired)— verifies stale entries trigger re-computationunstable_cache with no revalidate option caches indefinitely— verifiesrevalidateAtisnull(not0) when no revalidate is specified🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.