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 0d7da49
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 3 additions & 4 deletions packages/pg-pool/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,18 +356,17 @@ 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) {
// allow Node to exit if this is all that's left
tid.unref()
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 0d7da49

Please sign in to comment.