@@ -37,7 +37,7 @@ export class Worker {
3737 private readonly activeExecutions = new Set < WorkflowExecution > ( ) ;
3838 private running = false ;
3939 private loopPromise : Promise < void > | null = null ;
40- private idlePollAttempts = 0 ;
40+ private backoffAttempts = 0 ;
4141
4242 constructor ( options : WorkerOptions ) {
4343 this . backend = options . backend ;
@@ -62,7 +62,7 @@ export class Worker {
6262 async start ( ) : Promise < void > {
6363 if ( this . running ) return ;
6464 this . running = true ;
65- this . idlePollAttempts = 0 ;
65+ this . backoffAttempts = 0 ;
6666 this . loopPromise = this . runLoop ( ) ;
6767 await Promise . resolve ( ) ;
6868 }
@@ -121,15 +121,15 @@ export class Worker {
121121 const claimedCount = await this . tick ( ) ;
122122
123123 if ( claimedCount > 0 ) {
124- this . idlePollAttempts = 0 ;
124+ this . backoffAttempts = 0 ;
125125 } else {
126- this . idlePollAttempts += 1 ;
127- await sleep ( getIdlePollDelayMs ( this . idlePollAttempts ) ) ;
126+ this . backoffAttempts += 1 ;
127+ await sleep ( getPollBackoffDelayMs ( this . backoffAttempts ) ) ;
128128 }
129129 } catch ( error ) {
130130 console . error ( "Worker tick failed:" , error ) ;
131- this . idlePollAttempts += 1 ;
132- await sleep ( getIdlePollDelayMs ( this . idlePollAttempts ) ) ;
131+ this . backoffAttempts += 1 ;
132+ await sleep ( getPollBackoffDelayMs ( this . backoffAttempts ) ) ;
133133 }
134134 }
135135 }
@@ -287,17 +287,17 @@ function sleep(ms: number): Promise<void> {
287287}
288288
289289/**
290- * Compute idle polling delay with exponential backoff and jitter.
291- * @param idlePollAttempts - Number of consecutive idle poll attempts
290+ * Compute polling delay with exponential backoff and jitter.
291+ * @param backoffAttempts - Number of consecutive backoff attempts
292292 * @returns Delay in milliseconds
293293 */
294- function getIdlePollDelayMs ( idlePollAttempts : number ) : number {
294+ function getPollBackoffDelayMs ( backoffAttempts : number ) : number {
295295 const { initialIntervalMs, backoffCoefficient, maximumIntervalMs } =
296296 DEFAULT_POLL_BACKOFF_POLICY ;
297297
298298 const exponentialBackoffMs =
299299 initialIntervalMs *
300- Math . pow ( backoffCoefficient , Math . max ( 0 , idlePollAttempts - 1 ) ) ;
300+ Math . pow ( backoffCoefficient , Math . max ( 0 , backoffAttempts - 1 ) ) ;
301301
302302 const cappedBackoffMs = Math . min ( exponentialBackoffMs , maximumIntervalMs ) ;
303303
0 commit comments