mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-04 02:09:37 +02:00
Remove "function" in favor of () => {}
This commit is contained in:
parent
4e979c3e1b
commit
075f16caac
25 changed files with 85 additions and 90 deletions
|
@ -8,13 +8,11 @@ type RetryTransactionWrapperOptions = { errorMessage: string, arguments?: any[]
|
|||
function retryTransactionWrapper (functionToRetry: (... args) => Promise<any>, options: RetryTransactionWrapperOptions) {
|
||||
const args = options.arguments ? options.arguments : []
|
||||
|
||||
return transactionRetryer(
|
||||
function (callback) {
|
||||
functionToRetry.apply(this, args)
|
||||
return transactionRetryer(callback => {
|
||||
functionToRetry.apply(this, args)
|
||||
.then(result => callback(null, result))
|
||||
.catch(err => callback(err))
|
||||
}
|
||||
)
|
||||
})
|
||||
.catch(err => {
|
||||
// Do not throw the error, continue the process
|
||||
logger.error(options.errorMessage, err)
|
||||
|
@ -26,14 +24,12 @@ function transactionRetryer (func: Function) {
|
|||
retry({
|
||||
times: 5,
|
||||
|
||||
errorFilter: function (err) {
|
||||
errorFilter: err => {
|
||||
const willRetry = (err.name === 'SequelizeDatabaseError')
|
||||
logger.debug('Maybe retrying the transaction function.', { willRetry })
|
||||
return willRetry
|
||||
}
|
||||
}, func, function (err) {
|
||||
err ? rej(err) : res()
|
||||
})
|
||||
}, func, err => err ? rej(err) : res())
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue