diff --git a/lib/PoolConnection.js b/lib/PoolConnection.js index 1d84323fc..08c7fe277 100644 --- a/lib/PoolConnection.js +++ b/lib/PoolConnection.js @@ -16,6 +16,10 @@ function PoolConnection(pool, options) { } PoolConnection.prototype.release = function () { + if (!this._pool || this._pool._closed) { + return; + } + return this._pool.releaseConnection(this); }; diff --git a/test/integration/pool/test-destroy-connection.js b/test/integration/pool/test-destroy-connection.js index 01a3a70df..41b0873f2 100644 --- a/test/integration/pool/test-destroy-connection.js +++ b/test/integration/pool/test-destroy-connection.js @@ -11,5 +11,7 @@ pool.getConnection(function(err, connection) { assert.ok(pool._allConnections.length == 0); assert.ok(!connection._pool); + assert.doesNotThrow(function () { connection.release(); }); + pool.end(); });