11import { createHash } from "node:crypto" ;
22
3+ import { error } from "@opennextjs/aws/adapters/logger.js" ;
34import type { CacheEntryType , CacheValue } from "@opennextjs/aws/types/overrides.js" ;
45
56import { getCloudflareContext } from "../cloudflare-context.js" ;
@@ -50,7 +51,7 @@ export async function purgeCacheByTags(tags: string[]) {
5051export async function internalPurgeCacheByTags ( env : CloudflareEnv , tags : string [ ] ) {
5152 if ( ! env . CACHE_PURGE_ZONE_ID && ! env . CACHE_PURGE_API_TOKEN ) {
5253 // THIS IS A NO-OP
53- debugCache ( "purgeCacheByTags" , "No cache zone ID or API token provided. Skipping cache purge." ) ;
54+ error ( "No cache zone ID or API token provided. Skipping cache purge." ) ;
5455 return "missing-credentials" ;
5556 }
5657
@@ -71,17 +72,16 @@ export async function internalPurgeCacheByTags(env: CloudflareEnv, tags: string[
7172 ) ;
7273 if ( response . status === 429 ) {
7374 // Rate limit exceeded
74- debugCache ( "purgeCacheByTags" , " Rate limit exceeded. Skipping cache purge.") ;
75+ error ( "purgeCacheByTags: Rate limit exceeded. Skipping cache purge." ) ;
7576 return "rate-limit-exceeded" ;
7677 }
7778 const bodyResponse = ( await response . json ( ) ) as {
7879 success : boolean ;
7980 errors : Array < { code : number ; message : string } > ;
8081 } ;
8182 if ( ! bodyResponse . success ) {
82- debugCache (
83- "purgeCacheByTags" ,
84- "Cache purge failed. Errors:" ,
83+ error (
84+ "purgeCacheByTags: Cache purge failed. Errors:" ,
8585 bodyResponse . errors . map ( ( error ) => `${ error . code } : ${ error . message } ` )
8686 ) ;
8787 return "purge-failed" ;
0 commit comments