[PR #507] [MERGED] fix: share ISR dedup maps across RSC/SSR environments via Symbol.for() #629

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

📋 Pull Request Information

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

Base: mainHead: fix/isr-cache-cross-env-dedup


📝 Commits (1)

  • 0a43931 fix: share ISR dedup maps across RSC/SSR environments via Symbol.for()

📊 Changes

1 file changed (+14 additions, -3 deletions)

View changed files

📝 packages/vinext/src/server/isr-cache.ts (+14 -3)

📄 Description

Summary

  • pendingRegenerations and revalidateDurations in isr-cache.ts were plain module-level Maps, giving each Vite environment (RSC, SSR) its own copy
  • This meant dedup didn't work across environments — both could trigger regeneration for the same key simultaneously, defeating the thundering herd protection
  • Use Symbol.for() on globalThis to share a single Map instance across environments, matching the pattern already used in fetch-cache.ts

Spotted during review of #498 — the fetch cache dedup PR correctly used Symbol.for(), but isr-cache.ts had the same cross-environment sharing problem.

Test plan

  • All 31 existing isr-cache.test.ts tests pass (dedup, LRU eviction, waitUntil, error handling)
  • CI: full Vitest suite + 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/507 **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/isr-cache-cross-env-dedup` --- ### 📝 Commits (1) - [`0a43931`](https://github.com/cloudflare/vinext/commit/0a43931422c5eb0ab98326291f467b327a07a879) fix: share ISR dedup maps across RSC/SSR environments via Symbol.for() ### 📊 Changes **1 file changed** (+14 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `packages/vinext/src/server/isr-cache.ts` (+14 -3) </details> ### 📄 Description ## Summary - `pendingRegenerations` and `revalidateDurations` in `isr-cache.ts` were plain module-level `Map`s, giving each Vite environment (RSC, SSR) its own copy - This meant dedup didn't work across environments — both could trigger regeneration for the same key simultaneously, defeating the thundering herd protection - Use `Symbol.for()` on `globalThis` to share a single Map instance across environments, matching the pattern already used in `fetch-cache.ts` Spotted during review of #498 — the fetch cache dedup PR correctly used `Symbol.for()`, but `isr-cache.ts` had the same cross-environment sharing problem. ## Test plan - [x] All 31 existing `isr-cache.test.ts` tests pass (dedup, LRU eviction, waitUntil, error handling) - [ ] CI: full Vitest suite + 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:11 +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#629
No description provided.