Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • B bull
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 175
    • Issues 175
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 9
    • Merge requests 9
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OptimalBits
  • bull
  • Issues
  • #1346
Closed
Open
Issue created Jun 11, 2019 by Administrator@rootContributor

whenCurrentJobsFinished initializes bclient unnecessarily

Created by: gabegorelick

Description

Bull typically does a good job of lazily connecting to Redis. But the following code causes the blocking client to be initialized unnecessarily:

https://github.com/OptimalBits/bull/blob/c0ee6be03c6d47d60465d2bae0d2566d5bf0d661/lib/queue.js#L1140-L1147

If bclient hasn't been initialized yet, then we're connecting for no reason.

Minimal, Working Test code to reproduce the issue.

const Queue = require('bull');
const Redis = require('ioredis');

const queue = new Queue('foo', {
  createClient (type) {
    if (type === 'bclient') {
      // enforce that we don't waste connections for read-only queues
      throw new Error('This queue is read-only');
    }

    return new Redis();
  }
});
queue.whenCurrentJobsFinished();

Bull version

develop branch

Additional information

Also reproducible when calling queue.pause(true) since that calls whenCurrentJobsFinished internally. Workaround for that is to call queue.pause(true, true) so that whenCurrentJobsFinished is not called. But that only works if you're sure there are no jobs to wait for.

Assignee
Assign to
Time tracking