mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
chore: make transaction logs trace
This commit is contained in:
@@ -75,15 +75,17 @@ export const addTransactionCapability = (state: SignalKeyStore, logger: Logger,
|
||||
return prefetch(type, ids)
|
||||
},
|
||||
transaction: async(work) => {
|
||||
// if we're already in a transaction,
|
||||
// just execute what needs to be executed -- no commit required
|
||||
if(inTransaction) {
|
||||
await work()
|
||||
} else {
|
||||
logger.debug('entering transaction')
|
||||
logger.trace('entering transaction')
|
||||
inTransaction = true
|
||||
try {
|
||||
await work()
|
||||
if(Object.keys(mutations).length) {
|
||||
logger.debug('committing transaction')
|
||||
logger.trace('committing transaction')
|
||||
// retry mechanism to ensure we've some recovery
|
||||
// in case a transaction fails in the first attempt
|
||||
let tries = maxCommitRetries
|
||||
@@ -91,6 +93,7 @@ export const addTransactionCapability = (state: SignalKeyStore, logger: Logger,
|
||||
tries -= 1
|
||||
try {
|
||||
await state.set(mutations)
|
||||
logger.trace('committed transaction')
|
||||
break
|
||||
} catch(error) {
|
||||
logger.warn(`failed to commit ${Object.keys(mutations).length} mutations, tries left=${tries}`)
|
||||
@@ -98,7 +101,7 @@ export const addTransactionCapability = (state: SignalKeyStore, logger: Logger,
|
||||
}
|
||||
}
|
||||
} else {
|
||||
logger.debug('no mutations in transaction')
|
||||
logger.trace('no mutations in transaction')
|
||||
}
|
||||
} finally {
|
||||
inTransaction = false
|
||||
|
||||
Reference in New Issue
Block a user