@@ -130,22 +130,19 @@ export default class Cache {
130
130
async getFetchCache ( key : string , softTags ?: string [ ] , tags ?: string [ ] ) {
131
131
debug ( "get fetch cache" , { key, softTags, tags } ) ;
132
132
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 ;
137
136
138
137
const _lastModified = await globalThis . tagCache . getLastModified (
139
138
key ,
140
- lastModified ,
139
+ cachedEntry ?. lastModified ,
141
140
) ;
142
141
if ( _lastModified === - 1 ) {
143
142
// If some tags are stale we need to force revalidation
144
143
return null ;
145
144
}
146
145
147
- if ( value === undefined ) return null ;
148
-
149
146
// For cases where we don't have tags, we need to ensure that the soft tags are not being revalidated
150
147
// We only need to check for the path as it should already contain all the tags
151
148
if ( ( tags ?? [ ] ) . length === 0 ) {
@@ -159,7 +156,7 @@ export default class Cache {
159
156
if ( path ) {
160
157
const pathLastModified = await globalThis . tagCache . getLastModified (
161
158
path . replace ( "_N_T_/" , "" ) ,
162
- lastModified ,
159
+ cachedEntry . lastModified ,
163
160
) ;
164
161
if ( pathLastModified === - 1 ) {
165
162
// In case the path has been revalidated, we don't want to use the fetch cache
@@ -170,7 +167,7 @@ export default class Cache {
170
167
171
168
return {
172
169
lastModified : _lastModified ,
173
- value : value ,
170
+ value : cachedEntry . value ,
174
171
} as CacheHandlerValue ;
175
172
} catch ( e ) {
176
173
// We can usually ignore errors here as they are usually due to cache not being found
@@ -181,18 +178,22 @@ export default class Cache {
181
178
182
179
async getIncrementalCache ( key : string ) : Promise < CacheHandlerValue | null > {
183
180
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
+ }
186
186
187
- const meta = cacheData ? .meta ;
187
+ const meta = cachedEntry . value . meta ;
188
188
const _lastModified = await globalThis . tagCache . getLastModified (
189
189
key ,
190
- lastModified ,
190
+ cachedEntry ?. lastModified ,
191
191
) ;
192
192
if ( _lastModified === - 1 ) {
193
193
// If some tags are stale we need to force revalidation
194
194
return null ;
195
195
}
196
+ const cacheData = cachedEntry ?. value ;
196
197
const requestId = globalThis . __openNextAls . getStore ( ) ?. requestId ?? "" ;
197
198
globalThis . lastModified [ requestId ] = _lastModified ;
198
199
if ( cacheData ?. type === "route" ) {
0 commit comments