Skip to content

Commit 6acfa7a

Browse files
committed
don't pass error as argument when connection is expected
1 parent 33617dc commit 6acfa7a

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

lib/pool_connection.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,13 @@ function PoolConnection (pool, options) {
1313
// When a fatal error occurs the connection's protocol ends, which will cause
1414
// the connection to end as well, thus we only need to watch for the end event
1515
// and we will be notified of disconnects.
16-
this.on('end', this._removeFromPool);
17-
this.on('error', this._removeFromPool);
16+
var connection = this;
17+
this.on('end', function(err) {
18+
this._removeFromPool();
19+
});
20+
this.on('error', function(err) {
21+
this._removeFromPool();
22+
});
1823
}
1924

2025
PoolConnection.prototype.release = function () {
@@ -38,11 +43,11 @@ PoolConnection.prototype.end = function () {
3843
};
3944

4045
PoolConnection.prototype.destroy = function () {
41-
this._removeFromPool(this);
46+
this._removeFromPool();
4247
return Connection.prototype.destroy.apply(this, arguments);
4348
};
4449

45-
PoolConnection.prototype._removeFromPool = function (connection) {
50+
PoolConnection.prototype._removeFromPool = function () {
4651
if (!this._pool || this._pool._closed) {
4752
return;
4853
}

0 commit comments

Comments
 (0)