Add db error consts file (#165)
* Add db error consts file * Fixed typo in comment
This commit is contained in:
parent
7c4c314df4
commit
1a8ef31d39
3 changed files with 14 additions and 6 deletions
|
|
@ -7,6 +7,7 @@ const _ = require('lodash/fp')
|
|||
const express = require('express')
|
||||
const nmd = require('nano-markdown')
|
||||
|
||||
const dbErrorCodes = require('./db-error-codes')
|
||||
const options = require('./options')
|
||||
const logger = require('./logger')
|
||||
const configManager = require('./config-manager')
|
||||
|
|
@ -25,7 +26,6 @@ const argv = require('minimist')(process.argv.slice(2))
|
|||
|
||||
const CLOCK_SKEW = 60 * 1000
|
||||
const REQUEST_TTL = 3 * 60 * 1000
|
||||
const SERIALIZATION_FAILURE_CODE = '40001'
|
||||
|
||||
const pids = {}
|
||||
const reboots = {}
|
||||
|
|
@ -135,7 +135,12 @@ function postTx (req, res, next) {
|
|||
return res.json(tx)
|
||||
})
|
||||
.catch(err => {
|
||||
if (err.code === SERIALIZATION_FAILURE_CODE) return res.status(204).json({})
|
||||
// 204 so that l-m can ignore the error
|
||||
// this is fine because the request is polled and will be retried if needed.
|
||||
if (err.code === dbErrorCodes.SERIALIZATION_FAILURE) {
|
||||
logger.warn('Harmless DB conflict, the query will be retried.')
|
||||
return res.status(204).json({})
|
||||
}
|
||||
if (err instanceof E.StaleTxError) return res.status(409).json({})
|
||||
if (err instanceof E.RatchetError) return res.status(409).json({})
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue