Stop Preventing Process Exit #866
granthusbands
started this conversation in
Ideas
Replies: 1 comment
-
Actually, this is probably better as an issue, so I've raised #869 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
On Node, if PostgresJS has been used at all, the process won't exit naturally, as it has some number of pooled connections still open. It seems that people are expected to call sql.end() or such. However, I think there's a simpler solution for end users. If PostgresJS can call soc.unref() on idle connections entering the pool and call soc.ref() when they're taken back out of the pool, the idle connections will no longer keep the process alive.
To be clear, unref() tells node that the socket is not important enough to keep the process alive, and ref() tells it that the socket is again important enough. The documentation implies that it's a toggle, rather than a counter, so it should be low risk. Also note that it's probable that some timers (for idle timeout and such) will also need unref called on the object returned from setTimeout or setInterval. They can probably just stay unref.
Beta Was this translation helpful? Give feedback.
All reactions