diff --git a/lib/postgresql_interface.js b/lib/postgresql_interface.js index 71d6198f..ec427a9c 100644 --- a/lib/postgresql_interface.js +++ b/lib/postgresql_interface.js @@ -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() }) } diff --git a/lib/routes.js b/lib/routes.js index 41ccbf9e..83e8e774 100644 --- a/lib/routes.js +++ b/lib/routes.js @@ -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) {