Automattic / Automattic/kue

Job stuck in queue when exception is thrown in the job start callback

Open
#1,166 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
9.4k
Forks
858
PR merge metrics
No merged PRs in 30d

Description

Hello, if any exeption arise in the callback of the job save method, and the main process is killed because of this exception, the all the jobs will be stuck in the "queued" state, and when restarting the application and connecting workers, these queued jobs won't be processed.

```javascript
var job = queue.create('Some job', {
title: 'Some title'
}).attempts(3).save( function(err){
//SOME CODE THROWING ERROR HERE
cb(err)
});
```

Any ideas how to fix this issue?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at the queue.create(...).attempts(...).save(callback) flow shown in the issue and trace what happens when the callback throws before the process exits. Reproduce the restart with jobs left in the "queued" state, then determine what behavior should ensure those jobs are processed after workers reconnect.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js, redis
Domain
backend, distributed-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.