chore: comments and better error message
This commit is contained in:
parent
8b1cf46f77
commit
3f46614ff5
2 changed files with 3 additions and 4 deletions
|
|
@ -27,11 +27,9 @@ function atomic (tx, pi, fromClient) {
|
||||||
const isStale = fromClient && oldTx && (oldTx.txVersion >= tx.txVersion)
|
const isStale = fromClient && oldTx && (oldTx.txVersion >= tx.txVersion)
|
||||||
if (isStale) throw new E.StaleTxError({ txId: tx.id })
|
if (isStale) throw new E.StaleTxError({ txId: tx.id })
|
||||||
|
|
||||||
|
// Server doesn't bump version, so we just prevent from version being older.
|
||||||
const isStaleFromServer = !fromClient && oldTx && (oldTx.txVersion > tx.txVersion)
|
const isStaleFromServer = !fromClient && oldTx && (oldTx.txVersion > tx.txVersion)
|
||||||
if (isStaleFromServer) {
|
if (isStaleFromServer) throw new Error('Stale Error: server triggered', tx.id)
|
||||||
logger.info('trying to update older version of tx', JSON.stringify(tx))
|
|
||||||
return Promise.resolve()
|
|
||||||
}
|
|
||||||
|
|
||||||
return preProcess(t, oldTx, tx, pi)
|
return preProcess(t, oldTx, tx, pi)
|
||||||
.then(preProcessedTx => cashOutLow.upsert(t, oldTx, preProcessedTx))
|
.then(preProcessedTx => cashOutLow.upsert(t, oldTx, preProcessedTx))
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,7 @@ function diff (oldTx, newTx) {
|
||||||
return updatedTx['customerId'] = newTx['customerId']
|
return updatedTx['customerId'] = newTx['customerId']
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
// prevent dispense changing from 'true' to 'false'
|
||||||
case 'dispense':
|
case 'dispense':
|
||||||
if (!oldTx.dispense) {
|
if (!oldTx.dispense) {
|
||||||
return updatedTx[fieldKey] = newTx[fieldKey]
|
return updatedTx[fieldKey] = newTx[fieldKey]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue