import retry from "async-retry" ; const errorCodesNoRetry = [ 400 , 403 , 413 ] ; export const retryRequest = async ( requestPerformer , retryOpts ) : Promise < void > => { const doRequest = async ( bail ) => { try { await requestPerformer ( ) ; } catch ( error ) { if ( error . response && errorCodesNoRetry . includes ( error . response . status ) ) { bail ( error ) ; return ; } throw error ; } } ; return retry ( doRequest , retryOpts ) ; } ;