@@ -386,6 +386,7 @@ export class CacheHandler implements NextCacheHandler {
386386
387387 static async #readPagesRouterPage(
388388 cacheKey : string ,
389+ isFallback : boolean ,
389390 ) : Promise < CacheHandlerValue | null > {
390391 let cacheHandlerValue : CacheHandlerValue | null = null ;
391392 let pageHtmlHandle : fsPromises . FileHandle | null = null ;
@@ -417,9 +418,11 @@ export class CacheHandler implements NextCacheHandler {
417418 const [ pageHtmlFile , { mtimeMs } , pageData ] = await Promise . all ( [
418419 pageHtmlHandle . readFile ( 'utf-8' ) ,
419420 pageHtmlHandle . stat ( ) ,
420- fsPromises
421- . readFile ( pageDataPath , 'utf-8' )
422- . then ( ( data ) => JSON . parse ( data ) as object ) ,
421+ isFallback
422+ ? { }
423+ : fsPromises
424+ . readFile ( pageDataPath , 'utf-8' )
425+ . then ( ( data ) => JSON . parse ( data ) as object ) ,
423426 ] ) ;
424427
425428 if ( CacheHandler . #debug) {
@@ -849,14 +852,21 @@ export class CacheHandler implements NextCacheHandler {
849852 } ) ;
850853
851854 if ( ! cachedData && CacheHandler . #fallbackFalseRoutes. has ( cacheKey ) ) {
852- cachedData = await CacheHandler . #readPagesRouterPage( cacheKey ) ;
855+ cachedData = await CacheHandler . #readPagesRouterPage( cacheKey , false ) ;
853856
854857 // if we have a value from the file system, we should set it to the cache store
855858 if ( cachedData ) {
856859 await CacheHandler . #mergedHandler. set ( cacheKey , cachedData ) ;
857860 }
858861 }
859862
863+ if ( ctx . isFallback ) {
864+ cachedData = await CacheHandler . #readPagesRouterPage(
865+ cacheKey ,
866+ ctx . isFallback ,
867+ ) ;
868+ }
869+
860870 return cachedData ?? null ;
861871 }
862872
0 commit comments