Skip to content

Commit

Permalink
fix(connection): do not allow to set blockingConnection option (#2851)
Browse files Browse the repository at this point in the history
  • Loading branch information
roggervalf authored Nov 11, 2024
1 parent 624a086 commit 9391cc2
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 7 deletions.
5 changes: 4 additions & 1 deletion src/classes/queue-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export class QueueBase extends EventEmitter implements MinimalQueue {
closing: Promise<void> | undefined;

protected closed: boolean = false;
protected hasBlockingConnection: boolean = false;
protected scripts: Scripts;
protected connection: RedisConnection;
public readonly qualifiedName: string;
Expand All @@ -43,9 +44,11 @@ export class QueueBase extends EventEmitter implements MinimalQueue {
public readonly name: string,
public opts: QueueBaseOptions = { connection: {} },
Connection: typeof RedisConnection = RedisConnection,
hasBlockingConnection = false,
) {
super();

this.hasBlockingConnection = hasBlockingConnection;
this.opts = {
prefix: 'bull',
...opts,
Expand All @@ -62,7 +65,7 @@ export class QueueBase extends EventEmitter implements MinimalQueue {
this.connection = new Connection(
opts.connection,
isRedisInstance(opts.connection),
opts.blockingConnection,
hasBlockingConnection,
opts.skipVersionCheck,
);

Expand Down
2 changes: 1 addition & 1 deletion src/classes/queue-events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,9 @@ export class QueueEvents extends QueueBase {
connection: isRedisInstance(connection)
? (<RedisClient>connection).duplicate()
: connection,
blockingConnection: true,
},
Connection,
true,
);

this.opts = Object.assign(
Expand Down
1 change: 0 additions & 1 deletion src/classes/queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ export class Queue<
super(
name,
{
blockingConnection: false,
...opts,
},
Connection,
Expand Down
1 change: 1 addition & 0 deletions src/interfaces/queue-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export interface QueueBaseOptions {

/**
* Denotes commands should retry indefinitely.
* @deprecated
*/
blockingConnection?: boolean;

Expand Down
8 changes: 4 additions & 4 deletions tests/test_connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,18 +149,18 @@ describe('connection', () => {

describe('non-blocking', () => {
it('should not override any redis options', async () => {
connection = new IORedis(redisHost, { maxRetriesPerRequest: 20 });
const connection2 = new IORedis(redisHost, { maxRetriesPerRequest: 20 });

const queue = new QueueBase(queueName, {
connection,
blockingConnection: false,
const queue = new Queue(queueName, {
connection: connection2,
});

const options = <RedisOptions>(await queue.client).options;

expect(options.maxRetriesPerRequest).to.be.equal(20);

await queue.close();
await connection2.quit();
});
});

Expand Down

0 comments on commit 9391cc2

Please sign in to comment.