Failed stalled jobs don't fire global:failed event
Created by: svet93
The issue is that today when a job stalls more than the allowed number of times, it gets moved to failed, but the event doesn't get published. We noticed that because we were running a job that would start other child jobs and use the .finished() function in order to know when the work is done. However, if a job stalled, it never ended in the global:failed handler so the finished function never resolved.
it('should emit global:failed when a job has stalled more than allowable times', done => {
queue.on('completed', (/*job*/) => {
done(new Error('should not have completed'));
});
queue.process((/*job*/) => {
return delay(250);
});
queue.add({ foo: 'bar' });
const queue2 = utils.buildQueue('test events', {
settings: {
stalledInterval: 100,
maxStalledCount: 0
}
});
queue2.on('global:failed', (/*job*/) => {
queue2.close().then(done);
});
queue.on('active', () => {
queue2.startMoveUnlockedJobsToWait();
queue.close(true);
});
});