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 {
311311 if ( config ?. disableTagCache || config ?. disableIncrementalCache ) {
312312 return ;
313313 }
314+ const _tags = Array . isArray ( tags ) ? tags : [ tags ] ;
315+ if ( _tags . length === 0 ) {
316+ return ;
317+ }
318+
314319 try {
315- const _tags = Array . isArray ( tags ) ? tags : [ tags ] ;
316320 if ( globalThis . tagCache . mode === "nextMode" ) {
317321 const paths = ( await globalThis . tagCache . getPathsByTags ?.( _tags ) ) ?? [ ] ;
318322
@@ -336,6 +340,7 @@ export default class Cache {
336340 }
337341 return ;
338342 }
343+
339344 for ( const tag of _tags ) {
340345 debug ( "revalidateTag" , tag ) ;
341346 // Find all keys with the given tag
Original file line number Diff line number Diff line change @@ -587,6 +587,14 @@ describe("CacheHandler", () => {
587587 expect ( invalidateCdnHandler . invalidatePaths ) . not . toHaveBeenCalled ( ) ;
588588 } ) ;
589589
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+
590598 it ( "Should call writeTags and invalidateCdnHandler.invalidatePaths for nextMode that supports getPathsByTags" , async ( ) => {
591599 globalThis . tagCache . mode = "nextMode" ;
592600 globalThis . tagCache . getPathsByTags = vi
You can’t perform that action at this time.
0 commit comments