File tree Expand file tree Collapse file tree 4 files changed +18
-6
lines changed
packages/cloudflare/src/api/overrides/tag-cache Expand file tree Collapse file tree 4 files changed +18
-6
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " @opennextjs/cloudflare " : patch
3+ ---
4+
5+ refactor: account for empty tag list in tag cache
Original file line number Diff line number Diff line change @@ -14,7 +14,9 @@ export class D1NextModeTagCache implements NextModeTagCache {
1414
1515 async getLastRevalidated ( tags : string [ ] ) : Promise < number > {
1616 const { isDisabled, db } = this . getConfig ( ) ;
17- if ( isDisabled ) return 0 ;
17+ if ( isDisabled || tags . length === 0 ) {
18+ return 0 ;
19+ }
1820 try {
1921 const result = await db
2022 . prepare (
@@ -36,7 +38,9 @@ export class D1NextModeTagCache implements NextModeTagCache {
3638
3739 async hasBeenRevalidated ( tags : string [ ] , lastModified ?: number ) : Promise < boolean > {
3840 const { isDisabled, db } = this . getConfig ( ) ;
39- if ( isDisabled ) return false ;
41+ if ( isDisabled || tags . length === 0 ) {
42+ return false ;
43+ }
4044 try {
4145 const result = await db
4246 . prepare (
Original file line number Diff line number Diff line change @@ -130,8 +130,9 @@ class ShardedDOTagCache implements NextModeTagCache {
130130
131131 public async getLastRevalidated ( tags : string [ ] ) : Promise < number > {
132132 const { isDisabled } = this . getConfig ( ) ;
133- if ( isDisabled ) return 0 ;
134- if ( tags . length === 0 ) return 0 ; // No tags to check
133+ if ( isDisabled || tags . length === 0 ) {
134+ return 0 ;
135+ }
135136 const deduplicatedTags = Array . from ( new Set ( tags ) ) ; // We deduplicate the tags to avoid unnecessary requests
136137 try {
137138 const shardedTagGroups = this . groupTagsByDO ( { tags : deduplicatedTags } ) ;
@@ -177,7 +178,9 @@ class ShardedDOTagCache implements NextModeTagCache {
177178 */
178179 public async hasBeenRevalidated ( tags : string [ ] , lastModified ?: number ) : Promise < boolean > {
179180 const { isDisabled } = this . getConfig ( ) ;
180- if ( isDisabled ) return false ;
181+ if ( isDisabled || tags . length === 0 ) {
182+ return false ;
183+ }
181184 try {
182185 const shardedTagGroups = this . groupTagsByDO ( { tags } ) ;
183186 const shardedTagRevalidationOutcomes = await Promise . all (
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ export class KVNextModeTagCache implements NextModeTagCache {
2626
2727 async getLastRevalidated ( tags : string [ ] ) : Promise < number > {
2828 const kv = this . getKv ( ) ;
29- if ( ! kv ) {
29+ if ( ! kv || tags . length === 0 ) {
3030 return 0 ;
3131 }
3232
You can’t perform that action at this time.
0 commit comments