Skip to content

Commit

Permalink
fix: implement pool_connection end
Browse files Browse the repository at this point in the history
  • Loading branch information
dimov authored and dstankovd committed Nov 14, 2024
1 parent 21abf37 commit c396bd8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
4 changes: 2 additions & 2 deletions lib/base/pool.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class BasePool extends EventEmitter {
}
for (let i = 0; i < this._allConnections.length; i++) {
connection = this._allConnections.get(i);
connection._realEnd(endCB);
connection.end(endCB);
}
}

Expand Down Expand Up @@ -200,7 +200,7 @@ class BasePool extends EventEmitter {
Date.now() - this._freeConnections.get(0).lastActiveTime >
this.config.idleTimeout)
) {
this._freeConnections.get(0)._realEnd();
this._freeConnections.get(0).end();
}
} finally {
this._removeIdleTimeoutConnections();
Expand Down
16 changes: 3 additions & 13 deletions lib/base/pool_connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,9 @@ class BasePoolConnection extends BaseConnection {
this._pool.releaseConnection(this);
}

end() {
const err = new Error(
'Calling conn.end() to release a pooled connection is ' +
'deprecated. In next version calling conn.end() will be ' +
'restored to default conn.end() behavior. Use ' +
'conn.release() instead.',
);
this.emit('warn', err);
console.warn(err.message);
this.release();
end(callback) {
this._removeFromPool();
super.end(callback);
}

destroy() {
Expand All @@ -58,6 +51,3 @@ class BasePoolConnection extends BaseConnection {

BasePoolConnection.statementKey = BaseConnection.statementKey;
module.exports = BasePoolConnection;

// TODO: Remove this when we are removing PoolConnection#end
BasePoolConnection.prototype._realEnd = BaseConnection.prototype.end;

0 comments on commit c396bd8

Please sign in to comment.