Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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();
});
}
MySQL.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();
}
});
};
}).exec(function dropTableCb(err) {
if (err) {
return cb(err);
}
MySQL.releaseConnection({
connection: report.connection
}).exec(function releaseConnectionCb(err) {
if (err) {
return cb(err);
}
delete adapter.datastores[_.first(_.keys(adapter.datastores))];
return cb();
});
});
});
}).exec(function seedCb(err) {
if (err) {
return cb(err);
}
MySQL.releaseConnection({
connection: report.connection
}).exec(cb);
});
});