[PR #503] [MERGED] fix: MemoryCacheHandler revalidate:0 creates immediately-stale entries #625

Closed
opened 2026-05-06 13:09:09 +02:00 by BreizhHardware · 0 comments

📋 Pull Request Information

Original PR: https://github.com/cloudflare/vinext/pull/503
Author: @NathanDrake2406
Created: 3/12/2026
Status: Merged
Merged: 3/12/2026
Merged by: @james-elicx

Base: mainHead: fix/revalidate-zero-stale


📝 Commits (2)

  • 3ee7fd6 fix: MemoryCacheHandler revalidate:0 creates immediately-stale entries
  • 05a3f89 fix: revalidate:0 should skip cache storage entirely

📊 Changes

5 files changed (+118 additions, -20 deletions)

View changed files

📝 packages/vinext/src/cloudflare/kv-cache-handler.ts (+13 -11)
📝 packages/vinext/src/shims/cache.ts (+12 -5)
📝 tests/features.test.ts (+48 -2)
📝 tests/kv-cache-handler.test.ts (+43 -0)
📝 tests/shims.test.ts (+2 -2)

📄 Description

Summary

  • MemoryCacheHandler.set had two code paths for computing revalidateAt. The ctx path guarded with revalidate > 0, but the data path only checked typeof data.revalidate === "number" — letting revalidate: 0 set revalidateAt = Date.now(), creating immediately-stale entries.
  • This was inconsistent with KVCacheHandler which already had the > 0 guard on both paths, meaning the two handlers produced different staleness for the same input (Memory → immediately stale, KV → no TTL).
  • Adds the missing > 0 guard to MemoryCacheHandler.set to align both code paths and both cache handler implementations.

Test plan

  • Added test: data.revalidate:0 does not create immediately-stale entries
  • Added test: data.revalidate:0 behaves consistently with ctx.revalidate:0
  • Existing ISR cache tests pass (stale entries, fresh entries, tag invalidation)
  • Full features.test.ts suite passes (252 tests)
  • All cache-related tests pass (shims, fetch-cache, isr-cache, kv-cache-handler — 1063 tests)
  • CI: Format, Lint, Typecheck, Vitest, Playwright E2E

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/cloudflare/vinext/pull/503 **Author:** [@NathanDrake2406](https://github.com/NathanDrake2406) **Created:** 3/12/2026 **Status:** ✅ Merged **Merged:** 3/12/2026 **Merged by:** [@james-elicx](https://github.com/james-elicx) **Base:** `main` ← **Head:** `fix/revalidate-zero-stale` --- ### 📝 Commits (2) - [`3ee7fd6`](https://github.com/cloudflare/vinext/commit/3ee7fd62e8ecc25be17c60db85948d1ba83c5dab) fix: MemoryCacheHandler revalidate:0 creates immediately-stale entries - [`05a3f89`](https://github.com/cloudflare/vinext/commit/05a3f899b139afea1cc2cf4b91e68a434af22e76) fix: revalidate:0 should skip cache storage entirely ### 📊 Changes **5 files changed** (+118 additions, -20 deletions) <details> <summary>View changed files</summary> 📝 `packages/vinext/src/cloudflare/kv-cache-handler.ts` (+13 -11) 📝 `packages/vinext/src/shims/cache.ts` (+12 -5) 📝 `tests/features.test.ts` (+48 -2) 📝 `tests/kv-cache-handler.test.ts` (+43 -0) 📝 `tests/shims.test.ts` (+2 -2) </details> ### 📄 Description ## Summary - `MemoryCacheHandler.set` had two code paths for computing `revalidateAt`. The `ctx` path guarded with `revalidate > 0`, but the `data` path only checked `typeof data.revalidate === "number"` — letting `revalidate: 0` set `revalidateAt = Date.now()`, creating immediately-stale entries. - This was inconsistent with `KVCacheHandler` which already had the `> 0` guard on both paths, meaning the two handlers produced different staleness for the same input (Memory → immediately stale, KV → no TTL). - Adds the missing `> 0` guard to `MemoryCacheHandler.set` to align both code paths and both cache handler implementations. ## Test plan - [x] Added test: `data.revalidate:0` does not create immediately-stale entries - [x] Added test: `data.revalidate:0` behaves consistently with `ctx.revalidate:0` - [x] Existing ISR cache tests pass (stale entries, fresh entries, tag invalidation) - [x] Full `features.test.ts` suite passes (252 tests) - [x] All cache-related tests pass (`shims`, `fetch-cache`, `isr-cache`, `kv-cache-handler` — 1063 tests) - [ ] CI: Format, Lint, Typecheck, Vitest, Playwright E2E --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
BreizhHardware 2026-05-06 13:09:09 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/vinext#625
No description provided.