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

Unexpected deletion of the keyPrefix option #2083

Closed
nekocode opened this issue Jul 1, 2021 · 1 comment · Fixed by #2084
Closed

Unexpected deletion of the keyPrefix option #2083

nekocode opened this issue Jul 1, 2021 · 1 comment · Fixed by #2084
Labels

Comments

@nekocode
Copy link
Contributor

nekocode commented Jul 1, 2021

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:
nekocode@06feb31

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)

nekocode added a commit to nekocode/bull that referenced this issue Jul 1, 2021
nekocode added a commit to nekocode/bull that referenced this issue Jul 1, 2021
nekocode added a commit to nekocode/bull that referenced this issue Jul 1, 2021
manast pushed a commit that referenced this issue Jul 1, 2021
github-actions bot pushed a commit that referenced this issue Jul 1, 2021
## [3.22.10](v3.22.9...v3.22.10) (2021-07-01)

### Bug Fixes

* deep clone options ([#2083](#2083)) ([1e00a90](1e00a90))
@manast
Copy link
Member

manast commented Jul 1, 2021

🎉 This issue has been resolved in version 3.22.10 🎉

The release is available on:

Your semantic-release bot 📦🚀

@manast manast added the released label Jul 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants