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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Queue Scheduler doesn't close its redis client #1298

Closed
dor272 opened this issue Jun 30, 2022 · 1 comment
Closed

Queue Scheduler doesn't close its redis client #1298

dor272 opened this issue Jun 30, 2022 · 1 comment

Comments

@dor272
Copy link

dor272 commented Jun 30, 2022

Hi,
I have a class wrapping both a queue and it's queue scheduler.
the code looks something like that:

    constructor({
        queueName, queueOptions, redisOptions,
    }: QueueMessengerOptions) {
        super(redisOptions);
        this.queueName = queueName;
        this.queue = new Queue(this.queueName, { ...queueOptions, connection: this.redisClient });
        this.scheduler = new QueueScheduler(this.queueName, { connection: this.redisClient.duplicate() });
    }


    async close() {
        await Promise.all([
            this.queue.close(),
            this.scheduler.close(),
        ]);  
        return super.close();
    }

Since the scheduler requires a dedicated redis connection I duplicate the redisClient from super.
But when I close the scheduler the redis client is still connected. Am I supposed to manage that connection outside the scheduler?

I tried it on the latest version of bullmq - 1.86.4

Thanks.

@manast
Copy link
Contributor

manast commented Jul 1, 2022

Neither the Queue or the QueueScheduler takes ownership of the Redis connection if you pass a Redis client, so you need to close the connection yourself. In the QueueScheduler case, you do not need to perform a duplicate, this is done automatically by the QueueScheduler if needed, and will clean up any new connections it creates when you close it.

@dor272 dor272 closed this as completed Jul 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants