Skip to content

Commit 5a42911

Browse files
dimovdstankovd
dimov
authored andcommitted
fix: implement pool_connection end
1 parent e9b133c commit 5a42911

File tree

2 files changed

+6
-15
lines changed

2 files changed

+6
-15
lines changed

lib/base/pool.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ class BasePool extends EventEmitter {
121121
}
122122
for (let i = 0; i < this._allConnections.length; i++) {
123123
connection = this._allConnections.get(i);
124-
connection._realEnd(endCB);
124+
connection.end(endCB);
125125
}
126126
}
127127

@@ -200,7 +200,7 @@ class BasePool extends EventEmitter {
200200
Date.now() - this._freeConnections.get(0).lastActiveTime >
201201
this.config.idleTimeout)
202202
) {
203-
this._freeConnections.get(0)._realEnd();
203+
this._freeConnections.get(0).end();
204204
}
205205
} finally {
206206
this._removeIdleTimeoutConnections();

lib/base/pool_connection.js

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,10 @@ class BasePoolConnection extends BaseConnection {
2929
this._pool.releaseConnection(this);
3030
}
3131

32-
end() {
33-
const err = new Error(
34-
'Calling conn.end() to release a pooled connection is ' +
35-
'deprecated. In next version calling conn.end() will be ' +
36-
'restored to default conn.end() behavior. Use ' +
37-
'conn.release() instead.'
38-
);
39-
this.emit('warn', err);
40-
console.warn(err.message);
41-
this.release();
32+
33+
end(callback) {
34+
this._removeFromPool();
35+
super.end(callback);
4236
}
4337

4438
destroy() {
@@ -58,6 +52,3 @@ class BasePoolConnection extends BaseConnection {
5852

5953
BasePoolConnection.statementKey = BaseConnection.statementKey;
6054
module.exports = BasePoolConnection;
61-
62-
// TODO: Remove this when we are removing PoolConnection#end
63-
BasePoolConnection.prototype._realEnd = BaseConnection.prototype.end;

0 commit comments

Comments
 (0)