Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pool.end() resolves before the last pool.query() #3254

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix: wait for pool.end()
Because when you don't pass a callback to .end() it always returns a promise
asadbek2021 committed Jun 18, 2024
commit 5e91617294e12b1acf2dc43082cb1982a91fc25b
5 changes: 2 additions & 3 deletions packages/pg-pool/index.js
Original file line number Diff line number Diff line change
@@ -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) {
2 changes: 1 addition & 1 deletion packages/pg-pool/test/idle-timeout.js
Original file line number Diff line number Diff line change
@@ -50,7 +50,7 @@ describe('idle timeout', () => {
try {
yield Promise.race([removal, timeout])
} finally {
pool.end()
yield pool.end()
}
})
)