Node Bull Queue Error: Missing process handler for job type JOB_NAME

Viewed 1813

I am creating node bull queue and passing a dynamic name as an option to the Queue.add function

myQueue.add(`myJob-${val}`, {
    attempts: 3,
    removeOnFail: true
});

I am defining the process name as below for the above job

myQueue.process(`myJob-${val}`, async (job, callback) => {
    try {
        console.log('Processing job', job.id, job.data);
        callback();

    } catch (err) {
        console.log(err);
    }
});

However, I am getting below error

Job ID 1 failed Error: Missing process handler for job type myJob-123

How to correctly define the processor with a dynamic name value?

1 Answers

Shouldn't your 2nd argument to .add() be the Job data? The job options you are passing in as the 2nd argument are correct, but they should be third.

Possibly try this instead:

myQueue.add(`myJob-${val}`, { lorem: "ipsum" }, {
    attempts: 3,
    removeOnFail: true
});

In cases where I've received that same error of Missing process handler for job ___ it has been because I have added the job before the processor is running. When that issue is unavoidable increasing the attempts (like you did) to a number greater than 1 has fixed it. However, you're passing in those job options as the data, so the attempts won't affect your queue.

Related