@@ -11,15 +11,15 @@ import { DurableObject } from "cloudflare:workers";
1111const DEFAULT_MAX_REVALIDATION = 5 ;
1212const DEFAULT_REVALIDATION_TIMEOUT_MS = 10_000 ;
1313const DEFAULT_RETRY_INTERVAL_MS = 2_000 ;
14- const DEFAULT_MAX_NUM_REVALIDATIONS = 6 ;
14+ const DEFAULT_MAX_RETRIES = 6 ;
1515
1616interface FailedState {
1717 msg : QueueMessage ;
1818 retryCount : number ;
1919 nextAlarmMs : number ;
2020}
2121
22- export class DurableObjectQueueHandler extends DurableObject < CloudflareEnv > {
22+ export class DOQueueHandler extends DurableObject < CloudflareEnv > {
2323 // Ongoing revalidations are deduped by the deduplication id
2424 // Since this is running in waitUntil, we expect the durable object state to persist this during the duration of the revalidation
2525 // TODO: handle incremental cache with only eventual consistency (i.e. KV or R2/D1 with the optional cache layer on top)
@@ -35,7 +35,7 @@ export class DurableObjectQueueHandler extends DurableObject<CloudflareEnv> {
3535 readonly maxRevalidations : number ;
3636 readonly revalidationTimeout : number ;
3737 readonly revalidationRetryInterval : number ;
38- readonly maxRevalidationAttempts : number ;
38+ readonly maxRetries : number ;
3939 readonly disableSQLite : boolean ;
4040
4141 constructor ( ctx : DurableObjectState , env : CloudflareEnv ) {
@@ -57,9 +57,9 @@ export class DurableObjectQueueHandler extends DurableObject<CloudflareEnv> {
5757 ? parseInt ( env . NEXT_CACHE_DO_QUEUE_RETRY_INTERVAL_MS )
5858 : DEFAULT_RETRY_INTERVAL_MS ;
5959
60- this . maxRevalidationAttempts = env . NEXT_CACHE_DO_QUEUE_MAX_NUM_REVALIDATIONS
61- ? parseInt ( env . NEXT_CACHE_DO_QUEUE_MAX_NUM_REVALIDATIONS )
62- : DEFAULT_MAX_NUM_REVALIDATIONS ;
60+ this . maxRetries = env . NEXT_CACHE_DO_QUEUE_MAX_RETRIES
61+ ? parseInt ( env . NEXT_CACHE_DO_QUEUE_MAX_RETRIES )
62+ : DEFAULT_MAX_RETRIES ;
6363
6464 this . disableSQLite = env . NEXT_CACHE_DO_QUEUE_DISABLE_SQLITE === "true" ;
6565
@@ -199,10 +199,9 @@ export class DurableObjectQueueHandler extends DurableObject<CloudflareEnv> {
199199 let updatedFailedState : FailedState ;
200200
201201 if ( existingFailedState ) {
202- if ( existingFailedState . retryCount >= this . maxRevalidationAttempts ) {
203- // We give up after 6 retries and log the error
202+ if ( existingFailedState . retryCount >= this . maxRetries ) {
204203 error (
205- `The revalidation for ${ msg . MessageBody . host } ${ msg . MessageBody . url } has failed after 6 retries. It will not be tried again, but subsequent ISR requests will retry.`
204+ `The revalidation for ${ msg . MessageBody . host } ${ msg . MessageBody . url } has failed after ${ this . maxRetries } retries. It will not be tried again, but subsequent ISR requests will retry.`
206205 ) ;
207206 this . routeInFailedState . delete ( msg . MessageDeduplicationId ) ;
208207 return ;
0 commit comments