brianc / node-pg-pool

A connection pool for node-postgres
MIT License
180 stars 64 forks source link

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

Open ghost opened 4 years ago

ghost commented 4 years ago

The pool.end callback/promise should resolve after the last pool.query finishes but that doesn't happen:

pool.query(query).then(() => console.log('done'))
pool.query(query).then(() => console.log('done'))
pool.end().then(() => console.log('end'))

result:

done
end
done

this negatively affects my code because I have callbacks on both query() and end() and the end() callback needs to assume all the query() callbacks have already been called so it can shutdown the script etc. I tried looking into a fix but was more involved across repos will need to look again