Open gajus opened 4 years ago
I think (1) is cleared by pool.end()
(which is required for a process to end naturally). (2) is cleared by a successful connection, also required for a process to end naturally.
Have you seen a bug (in a minimal script) where pool timeouts are keeping the process running after ending the pool?
It occurred to me that this could be useful. The http.Agent class in Node.js unrefs sockets that are not currently handling an HTTP request, so they stick around in memory, but they don't stop the process from exiting if they're not actively being used.
So the question is: can pg-pool unref sockets or timeouts if they're not currently in use? Can I create a pool that will let the process end without calling pool.end() first?
@fluggo Yep, the pool could do that.
In at least two cases,
pg-pool
creates a referenced timeout:These timeouts are currently keeping the process from dying naturally.
Use
setTimeout().unref()
to prevent this.Unless I am overlooking a need to keep the pool awake?