diff --git a/lib/queue.js b/lib/queue.js index f8266eed9..f9bfd46b2 100755 --- a/lib/queue.js +++ b/lib/queue.js @@ -307,10 +307,10 @@ function redisClientGetter(queue, options, initCallback) { } function redisOptsFromUrl(urlString) { - const redisOpts = {}; + let redisOpts = {}; try { - const redisUrl = url.parse(urlString); - redisOpts.port = redisUrl.port || 6379; + const redisUrl = url.parse(urlString, true, true); + redisOpts.port = parseInt(redisUrl.port || '6379', 10); redisOpts.host = redisUrl.hostname; redisOpts.db = redisUrl.pathname ? redisUrl.pathname.split('/')[1] : 0; if (redisUrl.auth) { @@ -320,6 +320,10 @@ function redisOptsFromUrl(urlString) { redisOpts.username = redisUrl.auth.slice(0, columnIndex); } } + + if (redisUrl.query) { + redisOpts = { ...redisOpts, ...redisUrl.query }; + } } catch (e) { throw new Error(e.message); } diff --git a/package.json b/package.json index 6fc86a1ec..a34292b7c 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "cron-parser": "^4.2.1", "debuglog": "^1.0.0", "get-port": "^5.1.1", - "ioredis": "^4.27.0", + "ioredis": "^4.28.5", "lodash": "^4.17.21", "msgpackr": "^1.5.2", "p-timeout": "^3.2.0", diff --git a/test/test_connection.js b/test/test_connection.js index 7960f63f3..f2acaa2a5 100644 --- a/test/test_connection.js +++ b/test/test_connection.js @@ -215,4 +215,16 @@ describe('connection', () => { await queue.close(); }); + + it('should accept ioredis options on the query string', async () => { + queue = new Queue( + 'connection query string', + 'redis://localhost?tls=RedisCloudFixed' + ); + + expect(queue.clients[0].options).to.have.property('tls'); + expect(queue.clients[0].options.tls).to.have.property('ca'); + + await queue.close(); + }); }); diff --git a/yarn.lock b/yarn.lock index 6c804e557..f6efe3217 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3183,16 +3183,17 @@ into-stream@^6.0.0: from2 "^2.3.0" p-is-promise "^3.0.0" -ioredis@^4.27.0: - version "4.27.5" - resolved "https://registry.yarnpkg.com/ioredis/-/ioredis-4.27.5.tgz#b62192bb6198f8a5a02947902117150aef39b7f1" - integrity sha512-JJ3HzOzU6kgUk3gKhpx8kxEYn9ruI5TkpOtGvbw/hLyWxfC19T9uCZTgmw4Mci4al4aOCCMfAjYzJ7aqQkLbJg== +ioredis@^4.28.5: + version "4.28.5" + resolved "https://registry.yarnpkg.com/ioredis/-/ioredis-4.28.5.tgz#5c149e6a8d76a7f8fa8a504ffc85b7d5b6797f9f" + integrity sha512-3GYo0GJtLqgNXj4YhrisLaNNvWSNwSS2wS4OELGfGxH8I69+XfNdnmV1AyN+ZqMh0i7eX+SWjrwFKDBDgfBC1A== dependencies: cluster-key-slot "^1.1.0" debug "^4.3.1" denque "^1.1.0" lodash.defaults "^4.2.0" lodash.flatten "^4.4.0" + lodash.isarguments "^3.1.0" p-map "^2.1.0" redis-commands "1.7.0" redis-errors "^1.2.0" @@ -4021,6 +4022,11 @@ lodash.flattendeep@^4.4.0: resolved "https://registry.yarnpkg.com/lodash.flattendeep/-/lodash.flattendeep-4.4.0.tgz#fb030917f86a3134e5bc9bec0d69e0013ddfedb2" integrity sha1-+wMJF/hqMTTlvJvsDWngAT3f7bI= +lodash.isarguments@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz#2f573d85c6a24289ff00663b491c1d338ff3458a" + integrity sha1-L1c9hcaiQon/AGY7SRwdM4/zRYo= + lodash.ismatch@^4.4.0: version "4.4.0" resolved "https://registry.yarnpkg.com/lodash.ismatch/-/lodash.ismatch-4.4.0.tgz#756cb5150ca3ba6f11085a78849645f188f85f37"