-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Labels
Description
Hello,
File thin/pool.js has procedure
//---------------------------------------------------------------------------
// scanIdleConnection()
//
// scan connection list and removes idle connections from pool
//---------------------------------------------------------------------------
_scanIdleConnection() {
while ((this._usedConnectionList.size + this._freeConnectionList.length) >
this._poolMin && this._freeConnectionList.length > 0) {
const conn = this._freeConnectionList[this._freeConnectionList.length - 1];
if (Date.now() - conn._lastTimeUsed < this._poolTimeout * 1000) {
break;
}
this.eventEmitter.emit('_removePoolConnection', conn);
this._freeConnectionList.pop();
}
this._schedulerJob = null;
this._setScheduler();
}
Why in cycle pops only last elements of array _freeConnectionList?
I have some web requests. Each request get connection from the pool. First connection releases and pushes to _freeConnectionList and second connection pushes to _freeConnectionList. _lastTimeUsed of first connection may be earlier then second connection. While second connection did not timeout, while breakes and first connection with timeout will not pop. Other requests (not in same time) get new connection from last element of _freeConnectionList. This is real second connection. _lastTimeUsed of second connection changes.