File tree Expand file tree Collapse file tree 2 files changed +9
-4
lines changed
packages/cloudflare/src/api/overrides/tag-cache Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " @opennextjs/cloudflare " : patch
3
+ ---
4
+
5
+ fix(tagCache): gracefully handle empty tag list
Original file line number Diff line number Diff line change 1
1
import { error } from "@opennextjs/aws/adapters/logger.js" ;
2
2
import type { OpenNextConfig } from "@opennextjs/aws/types/open-next.js" ;
3
3
import type { NextModeTagCache } from "@opennextjs/aws/types/overrides.js" ;
4
- import { RecoverableError } from "@opennextjs/aws/utils/error.js" ;
5
4
6
5
import { getCloudflareContext } from "../../cloudflare-context.js" ;
7
6
import { debugCache , FALLBACK_BUILD_ID } from "../internal.js" ;
@@ -36,15 +35,16 @@ export class D1NextModeTagCache implements NextModeTagCache {
36
35
37
36
async writeTags ( tags : string [ ] ) : Promise < void > {
38
37
const { isDisabled, db } = this . getConfig ( ) ;
39
- if ( isDisabled ) return Promise . resolve ( ) ;
40
- const result = await db . batch (
38
+ // TODO: Remove `tags.length === 0` when https://github.com/opennextjs/opennextjs-aws/pull/828 is used
39
+ if ( isDisabled || tags . length === 0 ) return Promise . resolve ( ) ;
40
+
41
+ await db . batch (
41
42
tags . map ( ( tag ) =>
42
43
db
43
44
. prepare ( `INSERT INTO revalidations (tag, revalidatedAt) VALUES (?, ?)` )
44
45
. bind ( this . getCacheKey ( tag ) , Date . now ( ) )
45
46
)
46
47
) ;
47
- if ( ! result ) throw new RecoverableError ( `D1 insert failed for ${ tags } ` ) ;
48
48
}
49
49
50
50
private getConfig ( ) {
You can’t perform that action at this time.
0 commit comments