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

[Bug] constructor with options does not destructure redis property if it is a string #2663

Closed
Shinigami92 opened this issue Sep 11, 2023 · 3 comments · Fixed by #2664
Closed
Labels

Comments

@Shinigami92
Copy link
Contributor

Description

When passing redis connection as options object but it is a url, the url will not destructed

bull/lib/queue.js

Lines 85 to 129 in 4d197e8

const Queue = function Queue(name, url, opts) {
if (!(this instanceof Queue)) {
return new Queue(name, url, opts);
}
if (_.isString(url)) {
const clonedOpts = _.cloneDeep(opts || {});
opts = {
...clonedOpts,
redis: {
...redisOptsFromUrl(url),
...clonedOpts.redis
}
};
} else {
opts = _.cloneDeep(url || {});
}
if (!_.isObject(opts)) {
throw TypeError('Options must be a valid object');
}
if (opts.limiter) {
if (opts.limiter.max && opts.limiter.duration) {
this.limiter = opts.limiter;
} else {
throw new TypeError('Limiter requires `max` and `duration` options');
}
}
if (opts.defaultJobOptions) {
this.defaultJobOptions = opts.defaultJobOptions;
}
this.name = name;
this.token = uuid.v4();
opts.redis = {
enableReadyCheck: false,
...opts.redis
};
_.defaults(opts.redis, {
port: 6379,
host: '127.0.0.1',

If not passed as string, the if in line 90 will be omitted and then it be ignored via line 129 because this takes precedents over string

Minimal, Working Test code to reproduce the issue.

import Queue from 'bull';

new Queue<any>('name', { redis: 'redis://my.host/6379' }); // results in 127.0.0.1 ❌

new Queue<any>('name', 'redis://my.host/6379'); // results in my.host ✅

Bull version

4.11.3

Additional information

This took me around 4h to find out...

Copy link

stale bot commented Nov 10, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Nov 10, 2023
@Shinigami92
Copy link
Contributor Author

Please only mark issues and PRs as stale if there are reasons why e.g. they couldn't get reviewed or merged.
This behavior of marking issues as stale is not helping anyone.

@stale stale bot removed the wontfix label Nov 10, 2023
@manast
Copy link
Member

manast commented Nov 11, 2023

🎉 This issue has been resolved in version 4.11.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

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