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 11import { error } from "@opennextjs/aws/adapters/logger.js" ;
22import type { OpenNextConfig } from "@opennextjs/aws/types/open-next.js" ;
33import type { NextModeTagCache } from "@opennextjs/aws/types/overrides.js" ;
4- import { RecoverableError } from "@opennextjs/aws/utils/error.js" ;
54
65import { getCloudflareContext } from "../../cloudflare-context.js" ;
76import { debugCache , FALLBACK_BUILD_ID } from "../internal.js" ;
@@ -36,15 +35,16 @@ export class D1NextModeTagCache implements NextModeTagCache {
3635
3736 async writeTags ( tags : string [ ] ) : Promise < void > {
3837 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 (
4142 tags . map ( ( tag ) =>
4243 db
4344 . prepare ( `INSERT INTO revalidations (tag, revalidatedAt) VALUES (?, ?)` )
4445 . bind ( this . getCacheKey ( tag ) , Date . now ( ) )
4546 )
4647 ) ;
47- if ( ! result ) throw new RecoverableError ( `D1 insert failed for ${ tags } ` ) ;
4848 }
4949
5050 private getConfig ( ) {
You can’t perform that action at this time.
0 commit comments