Skip to content

Commit 243ffee

Browse files
asadbek2021hjr3
authored andcommitted
fix: wait for pool.end()
Because when you don't pass a callback to .end() it always returns a promise
1 parent 0188277 commit 243ffee

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

packages/pg-pool/index.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -365,16 +365,15 @@ class Pool extends EventEmitter {
365365
if (isExpired) {
366366
this.log('remove expired client')
367367
this._expired.delete(client)
368-
this._remove(client, this._pulseQueue.bind(this))
369-
return
368+
return this._remove(client, this._pulseQueue.bind(this))
370369
}
371370

372371
// idle timeout
373372
let tid
374373
if (this.options.idleTimeoutMillis && this._isAboveMin()) {
375374
tid = setTimeout(() => {
376375
this.log('remove idle client')
377-
this._remove(client)
376+
this._remove(client, this._pulseQueue.bind(this))
378377
}, this.options.idleTimeoutMillis)
379378

380379
if (this.options.allowExitOnIdle) {

packages/pg-pool/test/idle-timeout.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ describe('idle timeout', () => {
5050
try {
5151
yield Promise.race([removal, timeout])
5252
} finally {
53-
pool.end()
53+
yield pool.end()
5454
}
5555
})
5656
)

0 commit comments

Comments
 (0)