Connection leak when using TLS
Created by: plarsson
Description
When using TLS option the Redis client active connection just grows infinitely.
To reproduce; just open a bull queue and close it, the client connection is still active in redis.
After a lot of investigation of stunnel, ioredis, tls and various things I figured out the problem was actually in bull in the method whenCurrentJobsFinished() https://github.com/OptimalBits/bull/blob/master/lib/queue.js#L1172 where it tries to reconnect.
It's only happening for TLS which is weird. Why is this re-connect feature running on close?
If I remove this line everything works fine and I later noticed an undocumented flag on the close() - doNotWaitActive which also fixes my problem (then this function is not runned). So I guess I can go with that flag as a workaround for now.
Thanks for a nice project!
Minimal, Working Test code to reproduce the issue.
Open a bull queue with tls and close it.
Bull version
3.4.2