@@ -117,7 +117,13 @@ export class Waiter implements Wait {
117117 const step = steps . find ( ( step ) => step . name === this . input . stepToWaitFor ) ;
118118 if ( step && step . status !== 'completed' ) {
119119 this . info ( `✋Awaiting step completion from job ${ job . html_url } ...` ) ;
120- return this . pollAndWait ( secondsSoFar ) ;
120+ let pollingInterval = this . input . pollIntervalSeconds ;
121+ if ( this . input . exponentialBackoffRetries ) {
122+ pollingInterval = this . input . pollIntervalSeconds * ( 2 * this . attempt || 1 ) ;
123+ this . info ( `🔁 Attempt ${ this . attempt + 1 } , next will be in ${ pollingInterval } seconds` ) ;
124+ this . attempt ++ ;
125+ }
126+ return this . pollAndWait ( secondsSoFar , pollingInterval ) ;
121127 } else if ( step ) {
122128 this . info ( `Step ${ this . input . stepToWaitFor } completed from run ${ previousRun . html_url } ` ) ;
123129 return ;
@@ -130,7 +136,13 @@ export class Waiter implements Wait {
130136
131137 if ( job && job . status !== 'completed' ) {
132138 this . info ( `✋Awaiting job run completion from job ${ job . html_url } ...` ) ;
133- return this . pollAndWait ( secondsSoFar ) ;
139+ let pollingInterval = this . input . pollIntervalSeconds ;
140+ if ( this . input . exponentialBackoffRetries ) {
141+ pollingInterval = this . input . pollIntervalSeconds * ( 2 * this . attempt || 1 ) ;
142+ this . info ( `🔁 Attempt ${ this . attempt + 1 } , next will be in ${ pollingInterval } seconds` ) ;
143+ this . attempt ++ ;
144+ }
145+ return this . pollAndWait ( secondsSoFar , pollingInterval ) ;
134146 } else if ( job ) {
135147 this . info ( `Job ${ this . input . jobToWaitFor } completed from run ${ previousRun . html_url } ` ) ;
136148 return ;
@@ -149,11 +161,12 @@ export class Waiter implements Wait {
149161 this . attempt ++ ;
150162 }
151163
152- return this . pollAndWait ( secondsSoFar ) ;
164+ return this . pollAndWait ( secondsSoFar , pollingInterval ) ;
153165 } ;
154166
155- pollAndWait = async ( secondsSoFar ?: number ) => {
156- await new Promise ( ( resolve ) => setTimeout ( resolve , this . input . pollIntervalSeconds * 1000 ) ) ;
157- return this . wait ( ( secondsSoFar || 0 ) + this . input . pollIntervalSeconds ) ;
167+ pollAndWait = async ( secondsSoFar ?: number , pollingInterval ?: number ) => {
168+ const intervalToUse = pollingInterval || this . input . pollIntervalSeconds ;
169+ await new Promise ( ( resolve ) => setTimeout ( resolve , intervalToUse * 1000 ) ) ;
170+ return this . wait ( ( secondsSoFar || 0 ) + intervalToUse ) ;
158171 } ;
159172}
0 commit comments