tedious
tedious copied to clipboard
[FEATURE REQUEST] Connection socket ref/unref
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.
Hi @digitalBush, thanks for the suggestion. We'll take a look into this.