mirror of
https://github.com/brianc/node-postgres.git
synced 2025-12-08 20:16:25 +00:00
parent
43b8692019
commit
01fadd93d7
@ -372,8 +372,10 @@ class Pool extends EventEmitter {
|
||||
let tid
|
||||
if (this.options.idleTimeoutMillis && this._isAboveMin()) {
|
||||
tid = setTimeout(() => {
|
||||
this.log('remove idle client')
|
||||
this._remove(client, this._pulseQueue.bind(this))
|
||||
if (this._isAboveMin()) {
|
||||
this.log('remove idle client')
|
||||
this._remove(client, this._pulseQueue.bind(this))
|
||||
}
|
||||
}, this.options.idleTimeoutMillis)
|
||||
|
||||
if (this.options.allowExitOnIdle) {
|
||||
|
||||
@ -124,3 +124,19 @@ describe('pool size of 2', () => {
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
describe('pool min size', () => {
|
||||
it(
|
||||
'does not drop below min when clients released at same time',
|
||||
co.wrap(function* () {
|
||||
const pool = new Pool({ max: 2, min: 1, idleTimeoutMillis: 10 })
|
||||
const client = yield pool.connect()
|
||||
const client2 = yield pool.connect()
|
||||
client.release()
|
||||
client2.release()
|
||||
yield new Promise((resolve) => setTimeout(resolve, 20))
|
||||
expect(pool.idleCount).to.equal(1)
|
||||
return yield pool.end()
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user