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 {
14
14
15
15
async getLastRevalidated ( tags : string [ ] ) : Promise < number > {
16
16
const { isDisabled, db } = this . getConfig ( ) ;
17
- if ( isDisabled ) return 0 ;
17
+ if ( isDisabled || tags . length === 0 ) {
18
+ return 0 ;
19
+ }
18
20
try {
19
21
const result = await db
20
22
. prepare (
@@ -36,7 +38,9 @@ export class D1NextModeTagCache implements NextModeTagCache {
36
38
37
39
async hasBeenRevalidated ( tags : string [ ] , lastModified ?: number ) : Promise < boolean > {
38
40
const { isDisabled, db } = this . getConfig ( ) ;
39
- if ( isDisabled ) return false ;
41
+ if ( isDisabled || tags . length === 0 ) {
42
+ return false ;
43
+ }
40
44
try {
41
45
const result = await db
42
46
. prepare (
Original file line number Diff line number Diff line change @@ -130,8 +130,9 @@ class ShardedDOTagCache implements NextModeTagCache {
130
130
131
131
public async getLastRevalidated ( tags : string [ ] ) : Promise < number > {
132
132
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
+ }
135
136
const deduplicatedTags = Array . from ( new Set ( tags ) ) ; // We deduplicate the tags to avoid unnecessary requests
136
137
try {
137
138
const shardedTagGroups = this . groupTagsByDO ( { tags : deduplicatedTags } ) ;
@@ -177,7 +178,9 @@ class ShardedDOTagCache implements NextModeTagCache {
177
178
*/
178
179
public async hasBeenRevalidated ( tags : string [ ] , lastModified ?: number ) : Promise < boolean > {
179
180
const { isDisabled } = this . getConfig ( ) ;
180
- if ( isDisabled ) return false ;
181
+ if ( isDisabled || tags . length === 0 ) {
182
+ return false ;
183
+ }
181
184
try {
182
185
const shardedTagGroups = this . groupTagsByDO ( { tags } ) ;
183
186
const shardedTagRevalidationOutcomes = await Promise . all (
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ export class KVNextModeTagCache implements NextModeTagCache {
26
26
27
27
async getLastRevalidated ( tags : string [ ] ) : Promise < number > {
28
28
const kv = this . getKv ( ) ;
29
- if ( ! kv ) {
29
+ if ( ! kv || tags . length === 0 ) {
30
30
return 0 ;
31
31
}
32
32
You can’t perform that action at this time.
0 commit comments