diff --git a/src/classes/redis-connection.ts b/src/classes/redis-connection.ts index fa9892b77d..bcbbbe6e9e 100644 --- a/src/classes/redis-connection.ts +++ b/src/classes/redis-connection.ts @@ -12,13 +12,11 @@ import * as path from 'path'; const overrideMessage = [ 'BullMQ: WARNING! Your redis options maxRetriesPerRequest must be null and enableReadyCheck false', - 'and will be overrided by BullMQ.', + 'and will be overridden by BullMQ.', ].join(' '); -const deprecationMessage = [ - 'BullMQ: DEPRECATION WARNING! Your redis options maxRetriesPerRequest must be null and enableReadyCheck false.', - 'On the next versions having this settings will throw an exception', -].join(' '); +const connectionErrorMessage = `Using a redis instance with enableReadyCheck or maxRetriesPerRequest is not permitted. +See https://https://github.com/OptimalBits/bull/issues/1873`; export class RedisConnection extends EventEmitter { static minimumVersion = '5.0.0'; @@ -55,7 +53,12 @@ export class RedisConnection extends EventEmitter { options = (options).redisOptions; } - this.checkOptions(deprecationMessage, options); + if ( + (options).maxRetriesPerRequest || + options.enableReadyCheck + ) { + throw new Error(connectionErrorMessage); + } } this.handleClientError = (err: Error): void => { diff --git a/tests/test_connection.ts b/tests/test_connection.ts index bdc24b644d..30c390adbe 100644 --- a/tests/test_connection.ts +++ b/tests/test_connection.ts @@ -42,6 +42,32 @@ describe('connection', () => { checkOptions(await queue.client); }); + describe('when reusing connection with enableReadyCheck as true', () => { + it('throws an error', async () => { + const connection = new IORedis({ + maxRetriesPerRequest: null, + enableReadyCheck: true, + }); + + expect(() => new QueueBase(queueName, { connection })).to + .throw(`Using a redis instance with enableReadyCheck or maxRetriesPerRequest is not permitted. +See https://https://github.com/OptimalBits/bull/issues/1873`); + }); + }); + + describe('when reusing connection with maxRetriesPerRequest different than null', () => { + it('throws an error', async () => { + const connection = new IORedis({ + maxRetriesPerRequest: 1, + enableReadyCheck: false, + }); + + expect(() => new QueueBase(queueName, { connection })).to + .throw(`Using a redis instance with enableReadyCheck or maxRetriesPerRequest is not permitted. +See https://https://github.com/OptimalBits/bull/issues/1873`); + }); + }); + describe('when maxmemory-policy is different than noeviction in Redis', () => { it('throws an error', async () => { const opts = { diff --git a/tests/test_worker.ts b/tests/test_worker.ts index 59e23a212f..260ce770c1 100644 --- a/tests/test_worker.ts +++ b/tests/test_worker.ts @@ -654,7 +654,10 @@ describe('workers', function () { describe('when sharing a redis connection between workers', function () { it('should not close the connection', async () => { - const connection = new IORedis(); + const connection = new IORedis({ + maxRetriesPerRequest: null, + enableReadyCheck: false, + }); return new Promise((resolve, reject) => { connection.on('ready', async () => {