Skip to content

Commit

Permalink
feat: allow nested caching
Browse files Browse the repository at this point in the history
  • Loading branch information
wyattjoh committed Apr 25, 2024
1 parent 4288232 commit 743c93c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
8 changes: 5 additions & 3 deletions packages/next/src/server/app-render/dynamic-rendering.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,11 @@ export function trackDynamicFetch(
store: StaticGenerationStore,
expression: string
) {
if (store.prerenderState) {
postponeWithTracking(store.prerenderState, expression, store.urlPathname)
}
// If we aren't in a prerender, or we're in an unstable cache callback, we
// don't need to postpone.
if (!store.prerenderState || store.isUnstableCacheCallback) return

postponeWithTracking(store.prerenderState, expression, store.urlPathname)
}

function postponeWithTracking(
Expand Down
7 changes: 0 additions & 7 deletions packages/next/src/server/lib/patch-fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,13 +278,6 @@ function createPatchedFetcher(
return originFetch(input, init)
}

// If the current scope is within an unstable cache callback, then
// we shouldn't do any special treatment of fetch because the
// surrounding callback will already be cached.
if (staticGenerationStore.isUnstableCacheCallback) {
return originFetch(input, init)
}

const isRequestInput =
input &&
typeof input === 'object' &&
Expand Down

0 comments on commit 743c93c

Please sign in to comment.