diff --git a/lib/Pool.js b/lib/Pool.js index 251628f70..96446ca36 100644 --- a/lib/Pool.js +++ b/lib/Pool.js @@ -127,11 +127,18 @@ Pool.prototype.query = function (sql, values, cb) { } this.getConnection(function (err, conn) { - if (err) return cb(err); + if (err) { + if (typeof cb === 'function') { + cb(err); + } + return; + } conn.query(sql, values, function () { conn.release(); - cb.apply(this, arguments); + if (typeof cb === 'function') { + cb.apply(this, arguments); + } }); }); };