Unverified Commit 44304092 authored by Hendrik Liebau's avatar Hendrik Liebau Committed by GitHub

Discard prerendered route handler data from FS cache after revalidation (#81611)

After having revalidated a prerendered route handler, on the subsequent request we must discard the prerendered data from the file system cache, as we already do for pages and fetch caches as well.

> [!NOTE]  
> This PR is best reviewed with hidden whitespace changes.
parent 08209b9b
...@@ -101,8 +101,8 @@ export default class FileSystemCache implements CacheHandler { ...@@ -101,8 +101,8 @@ export default class FileSystemCache implements CacheHandler {
// let's check the disk for seed data // let's check the disk for seed data
if (!data && process.env.NEXT_RUNTIME !== 'edge') { if (!data && process.env.NEXT_RUNTIME !== 'edge') {
if (kind === IncrementalCacheKind.APP_ROUTE) {
try { try {
if (kind === IncrementalCacheKind.APP_ROUTE) {
const filePath = this.getFilePath( const filePath = this.getFilePath(
`${key}.body`, `${key}.body`,
IncrementalCacheKind.APP_ROUTE IncrementalCacheKind.APP_ROUTE
...@@ -117,7 +117,7 @@ export default class FileSystemCache implements CacheHandler { ...@@ -117,7 +117,7 @@ export default class FileSystemCache implements CacheHandler {
) )
) )
const cacheEntry: CacheHandlerValue = { data = {
lastModified: mtime.getTime(), lastModified: mtime.getTime(),
value: { value: {
kind: CachedRouteKind.APP_ROUTE, kind: CachedRouteKind.APP_ROUTE,
...@@ -126,13 +126,7 @@ export default class FileSystemCache implements CacheHandler { ...@@ -126,13 +126,7 @@ export default class FileSystemCache implements CacheHandler {
status: meta.status, status: meta.status,
}, },
} }
return cacheEntry } else {
} catch {
return null
}
}
try {
const filePath = this.getFilePath( const filePath = this.getFilePath(
kind === IncrementalCacheKind.FETCH ? key : `${key}.html`, kind === IncrementalCacheKind.FETCH ? key : `${key}.html`,
kind kind
...@@ -267,6 +261,7 @@ export default class FileSystemCache implements CacheHandler { ...@@ -267,6 +261,7 @@ export default class FileSystemCache implements CacheHandler {
`Invariant: Unexpected route kind ${kind} in file system cache.` `Invariant: Unexpected route kind ${kind} in file system cache.`
) )
} }
}
if (data) { if (data) {
FileSystemCache.memoryCache?.set(key, data) FileSystemCache.memoryCache?.set(key, data)
...@@ -278,6 +273,7 @@ export default class FileSystemCache implements CacheHandler { ...@@ -278,6 +273,7 @@ export default class FileSystemCache implements CacheHandler {
if ( if (
data?.value?.kind === CachedRouteKind.APP_PAGE || data?.value?.kind === CachedRouteKind.APP_PAGE ||
data?.value?.kind === CachedRouteKind.APP_ROUTE ||
data?.value?.kind === CachedRouteKind.PAGES data?.value?.kind === CachedRouteKind.PAGES
) { ) {
let cacheTags: undefined | string[] let cacheTags: undefined | string[]
......
...@@ -28,10 +28,7 @@ ...@@ -28,10 +28,7 @@
] ]
}, },
"test/e2e/app-dir/use-cache/use-cache.test.ts": { "test/e2e/app-dir/use-cache/use-cache.test.ts": {
"failed": [ "failed": ["use-cache should update after unstable_expireTag correctly"]
"use-cache should revalidate before redirecting in a route handler",
"use-cache should update after unstable_expireTag correctly"
]
}, },
"test/production/app-dir/browser-chunks/browser-chunks.test.ts": { "test/production/app-dir/browser-chunks/browser-chunks.test.ts": {
"failed": [ "failed": [
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment