Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.exec(function rollbackCb() {
// Only release the connection if the leased flag is false
if (leased) {
return cb();
}
// Release the connection back into the pool
PG.releaseConnection({
connection: connection
})
.exec(function releaseCb() {
return cb();
});
});
};
.exec(function releaseCb() {
return cb(err);
});
});
return;
}
// Only release the connection if it wasn't leased from outside the
// adapter.
if (leased) {
return cb();
}
// Release the connection back into the pool
PG.releaseConnection({
connection: connection
})
.exec(function releaseCb() {
return cb();
});
});
};
module.exports = function releaseConnection(connection, leased, cb) {
// If this connection was leased outside of the Adapter, don't release it.
if (leased) {
return setImmediate(function ensureAsync() {
return cb();
});
}
PG.releaseConnection({
connection: connection
}).switch({
error: function error(err) {
return cb(new Error('There was an error releasing the connection back into the pool.' + err.stack));
},
badConnection: function badConnection() {
return cb(new Error('Bad connection when trying to release an active connection.'));
},
success: function success() {
return cb();
}
});
};
error: function error(err) {
// If the connection was leased from outside the adapter, don't release it.
if (leased) {
return cb(new Error('There was an error starting a transaction. ' + err.stack));
}
PG.releaseConnection({
connection: connection
}).exec({
error: function error(err) {
return cb(new Error('There was an error releasing the connection back into the pool. ' + err.stack));
},
success: function success() {
return cb(new Error('There was an error starting a transaction. ' + err.stack));
}
});
},
success: function success() {
.exec(function rollbackCb() {
// Only release the connection if it wasn't leased from outside the
// adapter.
if (leased) {
return cb(err);
}
// Release the connection back into the pool
PG.releaseConnection({
connection: connection
})
.exec(function releaseCb() {
return cb(err);
});
});
}).exec(function seedCb(err) {
if (err) {
return cb(err);
}
PG.releaseConnection({
connection: report.connection
}).exec(cb);
});
});
}).exec(function dropTableCb(err) {
if (err) {
return cb(err);
}
PG.releaseConnection({
connection: report.connection
}).exec(function releaseConnectionCb(err) {
if (err) {
return cb(err);
}
delete adapter.datastores[_.first(_.keys(adapter.datastores))];
return cb();
});
});
});