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
  • #2083
Closed
Open
Issue created Jul 01, 2021 by Administrator@rootContributor

Unexpected deletion of the keyPrefix option

Created by: nekocode

Description

In latest code, the instantiation of queue will deleted keyPrefix property of the options object which we passed to the second function parameter:

if (_.isString(url)) {
  // ...
} else {
  opts = url || {};
}

// ...

delete opts.redis.keyPrefix;

It causes that we will loss the keyPrefix if we use one options instance to initialize multiple queues.

I think we should use a deep cloned options object to make sure the passed one will not be changed.

Minimal, Working Test code to reproduce the issue.

I wrote a test to reproduce the issue: https://github.com/nekocode/bull/commit/06feb3176c85891b7180b72ea7c20d3a4514c089

it('should not change the options object', async () => {
  const originalOptions = { redis: { keyPrefix: 'myQ' } };
  const options = _.cloneDeep(originalOptions);

  let queue = new Queue('q', 'redis://127.0.0.1', options);
  expect(_.isEqual(options, originalOptions)).to.be.true;
  await queue.close();

  queue = new Queue('q', options);
  expect(_.isEqual(options, originalOptions)).to.be.true;
  await queue.close();
});

Bull version

3.22.9 (latest)

Assignee
Assign to
Time tracking