Description
Is your feature request related to a problem? Please describe.
Currently it is easy to get Error: Connection is closed
error when Redis instance is reused across multiple workers and is explicitly managed by the application. In case you close all the workers and try to close the Redis connection, you will get Error: Connection is closed
, because BullMQ has already closed the connection by itself. It is also a potentially unwanted behaviour, because sometimes you may only stop one worker, but not destroy the connection for all other workers.
Describe the solution you'd like
Extra flag on worker.close()
method that would avoid terminating the Redis connection/closing client.
Describe alternatives you've considered
New method worker.stop()
which does the same thing as worker.close()
without terminating the Redis connection. If this is introduced, probably worker.close()
should start invoking worker.stop
as well to reduce the duplication.
If this is accepted, we can send a PR with the change.
This should also potentially address #2402