Description replace
export const genRetryOnFailurePolicy = (
retryCount : number ,
retryOverallDelay : number ,
) : AdditionalPolicyConfig => ( {
policy : {
name : 'retry-on-failure' ,
async sendRequest ( request , next ) {
const statusesToNotRetry = [ 200 , 400 , 403 ] ;
const intervals = new Array ( retryCount ) . fill ( 0 )
. map ( ( _ , idx ) => ( ( idx + 1 ) / retryCount ) ** 2 ) ;
const intervalSum = intervals . reduce ( ( a , b ) => a + b ) ;
const intervalsInMs = intervals . map ( ( el ) => ( el / intervalSum ) * retryOverallDelay ) ;
let error = new RestError ( 'Not expected to be thrown' ) ;
for ( let attempt = 0 ; attempt <= retryCount ; attempt += 1 ) {
if ( attempt !== 0 ) await pause ( intervalsInMs [ attempt - 1 ] ) ;
try {
return await next ( request ) ;
} catch ( e ) {
if ( ! ( e instanceof RestError ) ) throw e ;
if ( statusesToNotRetry . includes ( e . response ?. status ?? 0 ) ) throw e ;
error = e ;
}
}
throw error ;
} ,
} ,
position : 'perCall' ,
} ) ;
with
https://learn.microsoft.com/en-us/javascript/api/@azure/core-rest-pipeline/?view=azure-node-latest#@azure-core-rest-pipeline-exponentialretrypolicy
Reactions are currently unavailable
You can’t perform that action at this time.
replace
aepp-sdk-js/src/utils/autorest.ts
Lines 115 to 144 in 0dcb239
with
https://learn.microsoft.com/en-us/javascript/api/@azure/core-rest-pipeline/?view=azure-node-latest#@azure-core-rest-pipeline-exponentialretrypolicy