make requestPending into HTTP error to work with l-m retry

This commit is contained in:
Josh Harvey 2016-05-21 16:31:03 +03:00
parent 1d323b0647
commit 25d782a2c5
2 changed files with 6 additions and 3 deletions

View file

@ -583,8 +583,7 @@ function updateDispense (client, session, dispensed, cb) {
var values = [dispensed, 'initial_request', 'pending', session.fingerprint, session.id, true]
query(client, sql, values, function (err, results) {
if (err) return cb(err)
// DEBUG10
// if (results.rowCount === 0) return cb(new Error('No pending tx'))
if (results.rowCount === 0) return cb(new Error('No pending tx'))
cb()
})
}

View file

@ -360,7 +360,11 @@ function getFingerprint (req) {
function cachedResponse (req, res, next) {
return plugins.cachedResponse(session(req), req.path, req.method)
.then(r => r.body ? res.json(r.body) : next())
.then(r => {
if (!r.body) return next()
if (r.body.pendingRequest) return res.sendStatus(409)
res.json(r.body)
})
}
function cacheResponse (req, body) {