aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/database-utils.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/helpers/database-utils.ts')
-rw-r--r--server/helpers/database-utils.ts8
1 files changed, 4 insertions, 4 deletions
diff --git a/server/helpers/database-utils.ts b/server/helpers/database-utils.ts
index d62462d35..169b80065 100644
--- a/server/helpers/database-utils.ts
+++ b/server/helpers/database-utils.ts
@@ -1,10 +1,10 @@
1// TODO: import from ES6 when retry typing file will include errorFilter function 1// TODO: import from ES6 when retry typing file will include errorFilter function
2import * as retry from 'async/retry' 2import * as retry from 'async/retry'
3 3import * as Bluebird from 'bluebird'
4import { logger } from './logger' 4import { logger } from './logger'
5 5
6type RetryTransactionWrapperOptions = { errorMessage: string, arguments?: any[] } 6type RetryTransactionWrapperOptions = { errorMessage: string, arguments?: any[] }
7function retryTransactionWrapper (functionToRetry: (...args) => Promise<any>, options: RetryTransactionWrapperOptions) { 7function retryTransactionWrapper (functionToRetry: (...args) => Promise<any> | Bluebird<any>, options: RetryTransactionWrapperOptions) {
8 const args = options.arguments ? options.arguments : [] 8 const args = options.arguments ? options.arguments : []
9 9
10 return transactionRetryer(callback => { 10 return transactionRetryer(callback => {
@@ -13,8 +13,8 @@ function retryTransactionWrapper (functionToRetry: (...args) => Promise<any>, op
13 .catch(err => callback(err)) 13 .catch(err => callback(err))
14 }) 14 })
15 .catch(err => { 15 .catch(err => {
16 // Do not throw the error, continue the process
17 logger.error(options.errorMessage, err) 16 logger.error(options.errorMessage, err)
17 throw err
18 }) 18 })
19} 19}
20 20
@@ -28,7 +28,7 @@ function transactionRetryer (func: Function) {
28 logger.debug('Maybe retrying the transaction function.', { willRetry }) 28 logger.debug('Maybe retrying the transaction function.', { willRetry })
29 return willRetry 29 return willRetry
30 } 30 }
31 }, func, err => err ? rej(err) : res()) 31 }, func, (err, data) => err ? rej(err) : res(data))
32 }) 32 })
33} 33}
34 34