Skip to content

Commit

Permalink
fix: wait for pool.end()
Browse files Browse the repository at this point in the history
Because when you don't pass a callback to .end() it always returns a promise
  • Loading branch information
asadbek2021 committed Jun 18, 2024
1 parent e81fc3d commit 5e91617
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions packages/pg-pool/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,16 +356,15 @@ class Pool extends EventEmitter {
if (isExpired) {
this.log('remove expired client')
this._expired.delete(client)
this._remove(client, this._pulseQueue.bind(this))
return
return this._remove(client, this._pulseQueue.bind(this))
}

// idle timeout
let tid
if (this.options.idleTimeoutMillis) {
tid = setTimeout(() => {
this.log('remove idle client')
this._remove(client)
this._remove(client, this._pulseQueue.bind(this))
}, this.options.idleTimeoutMillis)

if (this.options.allowExitOnIdle) {
Expand Down
2 changes: 1 addition & 1 deletion packages/pg-pool/test/idle-timeout.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe('idle timeout', () => {
try {
yield Promise.race([removal, timeout])
} finally {
pool.end()
yield pool.end()
}
})
)
Expand Down

0 comments on commit 5e91617

Please sign in to comment.