Skip to content

Commit

Permalink
more fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk committed Mar 29, 2024
1 parent 573f23d commit 2ca21ee
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/next/src/server/lib/patch-fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,7 @@ export function patchFetch({

let handleUnlock = () => Promise.resolve()
let cacheReasonOverride
let isForegroundRevalidate = false

if (cacheKey && staticGenerationStore.incrementalCache) {
handleUnlock = await staticGenerationStore.incrementalCache.lock(
Expand Down Expand Up @@ -585,7 +586,9 @@ export function patchFetch({
if (entry?.value && entry.value.kind === 'FETCH') {
// when stale and is revalidating we wait for fresh data
// so the revalidated entry has the updated data
if (!(staticGenerationStore.isRevalidate && entry.isStale)) {
if (staticGenerationStore.isRevalidate && entry.isStale) {
isForegroundRevalidate = true
} else {
if (entry.isStale) {
staticGenerationStore.pendingRevalidates ??= {}
if (!staticGenerationStore.pendingRevalidates[cacheKey]) {
Expand Down Expand Up @@ -692,7 +695,7 @@ export function patchFetch({
// if we are revalidating the whole page via time or on-demand and
// the fetch cache entry is stale we should still de-dupe the
// origin hit if it's a cache-able entry
if (cacheKey) {
if (cacheKey && isForegroundRevalidate) {
staticGenerationStore.pendingRevalidates ??= {}
const pendingRevalidate =
staticGenerationStore.pendingRevalidates[cacheKey]
Expand Down

0 comments on commit 2ca21ee

Please sign in to comment.