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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE REQUEST] Connection socket ref/unref #1591

Open
digitalBush opened this issue Nov 14, 2023 · 1 comment
Open

[FEATURE REQUEST] Connection socket ref/unref #1591

digitalBush opened this issue Nov 14, 2023 · 1 comment

Comments

@digitalBush
Copy link

I'm happy to have a go at this. I just wanted to float the idea first and see what you all think. 馃憤

Is your feature request related to a problem? If so, please give a short summary of the problem and how the feature would resolve it

I have a connection pool that wraps tedious connections. With some of our integration tests, we spin up an app and don't have a easy reference to the pool (and the connections underneath). With an idle connection, the test exit hangs.

It would be nice if the connection's socket was ref/unref'd as it was in use or idle. This would allow the node process to shut down even with an open connection.

Describe the preferred solution
This could be a connection config option, though I'm not sure if there is any harm in making it a default behavior.

Describe alternatives you've considered
I currently have access to the socket property on the connection and can successfully ref/unref from outside. That property is marked private though, so I was reluctant to solve it this way in case the connection internals change.

Of course, fixing the tests to properly dispose the pool is the best alternative. 馃槃

Additional context
We use generic-pool and they also unref their timers to prevent blocking node's exit. generic-pool

Reference Documentations/Specifications
Node docs are here: unref and ref.

@mShan0
Copy link
Contributor

mShan0 commented Nov 15, 2023

Hi @digitalBush, thanks for the suggestion. We'll take a look into this.

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

No branches or pull requests

2 participants