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

PostgresJS Prevents Natural Process Exit #869

Open
granthusbands opened this issue May 16, 2024 · 0 comments
Open

PostgresJS Prevents Natural Process Exit #869

granthusbands opened this issue May 16, 2024 · 0 comments

Comments

@granthusbands
Copy link

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 set a low connection timeout. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant