Skip to content

Commit

Permalink
Merge pull request OptimalBits#1552 from gabegorelick/pause-bclient
Browse files Browse the repository at this point in the history
fix(pause): don't initialize bclient if not waiting for jobs to finish
  • Loading branch information
manast authored Nov 8, 2019
2 parents 8c06c5f + 39bb48c commit d36ce22
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/queue.js
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,11 @@ Queue.prototype.pause = function(isLocal, doNotWaitActive) {
});
}

if (!this.bclientInitialized) {
// bclient not yet initialized, so no jobs to wait for
return;
}

if (doNotWaitActive) {
// Force reconnection of blocking connection to abort blocking redis call immediately.
return redisClientDisconnect(this.bclient).then(() => {
Expand Down
11 changes: 11 additions & 0 deletions test/test_pause.js
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,17 @@ describe('.pause', () => {
'getNextJob should return without getting job'
);
});

it('should not initialize blocking client if not already initialized', async () => {
const createClient = sinon.spy(() => client);
const queue = utils.buildQueue('pause-queue', { createClient });

await queue.pause(true, true);
const bClientCalls = createClient
.getCalls()
.filter(c => c.args[0] === 'bclient');
expect(bClientCalls).to.have.lengthOf(0);
});
});
});
});

0 comments on commit d36ce22

Please sign in to comment.