Skip to content

Commit

Permalink
Merge branch 'v3.0.0' into sanitized-options
Browse files Browse the repository at this point in the history
  • Loading branch information
manast committed Apr 23, 2017
2 parents d5abe9f + ffde743 commit 616249c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 19 deletions.
2 changes: 1 addition & 1 deletion lib/job.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ Job.prototype.moveToFailed = function(err, ignoreLock){
reject();
}else{
if(result === -1){
reject(new Error('Missing Job ' + jobId + ' during retry'));
reject(new Error('Missing Job ' + _this.id + ' during retry'));
}
}
});
Expand Down
33 changes: 15 additions & 18 deletions lib/queue.js
Original file line number Diff line number Diff line change
Expand Up @@ -700,17 +700,15 @@ Queue.prototype.processJob = function(job){
//
var lockExtender = function(){
lockRenewId = _this.timers.set('lockExtender', _this.settings.lockRenewTime, function(){
if(!timerStopped){
scripts.extendLock(_this, job.id).then(function(lock){
if(lock){
lockExtender();
}
}).catch(function(err){
// Somehow tell the worker this job should stop processing...
});
}
scripts.extendLock(_this, job.id).then(function(lock){
if(lock && !timerStopped){
lockExtender();
}
}).catch(function(err){
// Somehow tell the worker this job should stop processing...
});
});
}
};

var timeoutMs = job.opts.timeout;

Expand All @@ -728,9 +726,7 @@ Queue.prototype.processJob = function(job){

return job.moveToCompleted(result).then(function(){
return _this.distEmit('completed', job, result, 'active');
}).finally(function(){
stopTimer();
})
});
}

function handleFailed(err){
Expand All @@ -739,12 +735,10 @@ Queue.prototype.processJob = function(job){
// See https://github.com/OptimalBits/bull/pull/415#issuecomment-269744735
return job.moveToFailed(err).then(function(){
return _this.distEmit('failed', job, error, 'active');
}).finally(function(){
stopTimer();
})
});
}

lockExtender()
lockExtender();
var handler = _this.handlers[job.name];
if(!handler){
return handleFailed(Error('Missing process handler for job type ' + job.name));
Expand All @@ -757,7 +751,10 @@ Queue.prototype.processJob = function(job){

_this.distEmit('active', job, jobPromise, 'waiting');

return jobPromise.then(handleCompleted, handleFailed);
return jobPromise.then(handleCompleted, handleFailed)
.finally(function(){
stopTimer();
});
}
};

Expand Down

0 comments on commit 616249c

Please sign in to comment.