- // Do not return the error, continue the process
- return finalCallback(null)
- }
- )
+function retryTransactionWrapper <T> (
+ functionToRetry: (...args: any[]) => Promise<T> | Bluebird<T>,
+ ...args: any[]
+): Promise<T> {
+ return transactionRetryer<T>(callback => {
+ functionToRetry.apply(null, args)
+ .then((result: T) => callback(null, result))
+ .catch(err => callback(err))
+ })
+ .catch(err => {
+ logger.error(`Cannot execute ${functionToRetry.name} with many retries.`, { err })
+ throw err
+ })