File tree Expand file tree Collapse file tree 3 files changed +19
-1
lines changed
tests-unit/tests/adapters Expand file tree Collapse file tree 3 files changed +19
-1
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " @opennextjs/aws " : patch
3
+ ---
4
+
5
+ fix(tagCache): do not call writeTags with an empty list
Original file line number Diff line number Diff line change @@ -311,8 +311,12 @@ export default class Cache {
311
311
if ( config ?. disableTagCache || config ?. disableIncrementalCache ) {
312
312
return ;
313
313
}
314
+ const _tags = Array . isArray ( tags ) ? tags : [ tags ] ;
315
+ if ( _tags . length === 0 ) {
316
+ return ;
317
+ }
318
+
314
319
try {
315
- const _tags = Array . isArray ( tags ) ? tags : [ tags ] ;
316
320
if ( globalThis . tagCache . mode === "nextMode" ) {
317
321
const paths = ( await globalThis . tagCache . getPathsByTags ?.( _tags ) ) ?? [ ] ;
318
322
@@ -336,6 +340,7 @@ export default class Cache {
336
340
}
337
341
return ;
338
342
}
343
+
339
344
for ( const tag of _tags ) {
340
345
debug ( "revalidateTag" , tag ) ;
341
346
// Find all keys with the given tag
Original file line number Diff line number Diff line change @@ -587,6 +587,14 @@ describe("CacheHandler", () => {
587
587
expect ( invalidateCdnHandler . invalidatePaths ) . not . toHaveBeenCalled ( ) ;
588
588
} ) ;
589
589
590
+ it ( "Should not call writeTags when the tag list is empty for nextMode" , async ( ) => {
591
+ globalThis . tagCache . mode = "nextMode" ;
592
+ await cache . revalidateTag ( [ ] ) ;
593
+
594
+ expect ( tagCache . writeTags ) . not . toHaveBeenCalled ( ) ;
595
+ expect ( invalidateCdnHandler . invalidatePaths ) . not . toHaveBeenCalled ( ) ;
596
+ } ) ;
597
+
590
598
it ( "Should call writeTags and invalidateCdnHandler.invalidatePaths for nextMode that supports getPathsByTags" , async ( ) => {
591
599
globalThis . tagCache . mode = "nextMode" ;
592
600
globalThis . tagCache . getPathsByTags = vi
You can’t perform that action at this time.
0 commit comments