@@ -130,22 +130,19 @@ export default class Cache {
130130 async getFetchCache ( key : string , softTags ?: string [ ] , tags ?: string [ ] ) {
131131 debug ( "get fetch cache" , { key, softTags, tags } ) ;
132132 try {
133- const { value, lastModified } = await globalThis . incrementalCache . get (
134- key ,
135- true ,
136- ) ;
133+ const cachedEntry = await globalThis . incrementalCache . get ( key , true ) ;
134+
135+ if ( cachedEntry ?. value === undefined ) return null ;
137136
138137 const _lastModified = await globalThis . tagCache . getLastModified (
139138 key ,
140- lastModified ,
139+ cachedEntry ?. lastModified ,
141140 ) ;
142141 if ( _lastModified === - 1 ) {
143142 // If some tags are stale we need to force revalidation
144143 return null ;
145144 }
146145
147- if ( value === undefined ) return null ;
148-
149146 // For cases where we don't have tags, we need to ensure that the soft tags are not being revalidated
150147 // We only need to check for the path as it should already contain all the tags
151148 if ( ( tags ?? [ ] ) . length === 0 ) {
@@ -159,7 +156,7 @@ export default class Cache {
159156 if ( path ) {
160157 const pathLastModified = await globalThis . tagCache . getLastModified (
161158 path . replace ( "_N_T_/" , "" ) ,
162- lastModified ,
159+ cachedEntry . lastModified ,
163160 ) ;
164161 if ( pathLastModified === - 1 ) {
165162 // In case the path has been revalidated, we don't want to use the fetch cache
@@ -170,7 +167,7 @@ export default class Cache {
170167
171168 return {
172169 lastModified : _lastModified ,
173- value : value ,
170+ value : cachedEntry . value ,
174171 } as CacheHandlerValue ;
175172 } catch ( e ) {
176173 // We can usually ignore errors here as they are usually due to cache not being found
@@ -181,18 +178,22 @@ export default class Cache {
181178
182179 async getIncrementalCache ( key : string ) : Promise < CacheHandlerValue | null > {
183180 try {
184- const { value : cacheData , lastModified } =
185- await globalThis . incrementalCache . get ( key , false ) ;
181+ const cachedEntry = await globalThis . incrementalCache . get ( key , false ) ;
182+
183+ if ( ! cachedEntry ?. value ) {
184+ return null ;
185+ }
186186
187- const meta = cacheData ? .meta ;
187+ const meta = cachedEntry . value . meta ;
188188 const _lastModified = await globalThis . tagCache . getLastModified (
189189 key ,
190- lastModified ,
190+ cachedEntry ?. lastModified ,
191191 ) ;
192192 if ( _lastModified === - 1 ) {
193193 // If some tags are stale we need to force revalidation
194194 return null ;
195195 }
196+ const cacheData = cachedEntry ?. value ;
196197 const requestId = globalThis . __openNextAls . getStore ( ) ?. requestId ?? "" ;
197198 globalThis . lastModified [ requestId ] = _lastModified ;
198199 if ( cacheData ?. type === "route" ) {
0 commit comments