Skip to content

Provide an option to opt-out of automatic Redis connection closing on worker.close #2437

Closed
@kibertoad

Description

@kibertoad

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions