diff --git a/packages/next/src/server/lib/incremental-cache/fetch-cache.ts b/packages/next/src/server/lib/incremental-cache/fetch-cache.ts index f00da82b107fe..9e8467f3176e1 100644 --- a/packages/next/src/server/lib/incremental-cache/fetch-cache.ts +++ b/packages/next/src/server/lib/incremental-cache/fetch-cache.ts @@ -253,14 +253,16 @@ export default class FetchCache implements CacheHandler { throw new Error(`invalid response from cache ${res.status}`) } - const cached: IncrementalCacheValue = await res.json() - const cachedParsed = zCachedFetchValue.safeParse(cached) + const json: IncrementalCacheValue = await res.json() + const parsed = zCachedFetchValue.safeParse(json) - if (!cachedParsed.success) { - this.debug && console.log({ cached }) + if (!parsed.success) { + this.debug && console.log({ json }) throw new Error('invalid cache value') } + const { data: cached } = parsed + // if new tags were specified, merge those tags to the existing tags if (cached.kind === 'FETCH') { cached.tags ??= []