bullmq icon indicating copy to clipboard operation
bullmq copied to clipboard

Error: Missing lock for job XXX. moveToFinished

Open PDB6912 opened this issue 7 months ago • 8 comments

Perform moveToFailed on the job in active, and when the job finishes, it throws an exception Error: Missing lock for job XXX. moveToFinished.

Version of bullmq in use is latest (5.).

Excerpts from code:

import { Worker, Job, Queue } from "bullmq";

const connection = {
  host: 'localhost',
  port: 6396,
  password: "",
}
const test = async () => {

  const queue = new Queue('test', { connection })
  const worker = new Worker('test', async (job: Job) => {
    console.log('start')
    await new Promise(resolve => setTimeout(resolve, 10000));
    console.log('end')
    return true
  }, {
    connection,
    concurrency: 1
  })
  const job = await queue.add('test', {})
  setTimeout(async () => {
    console.log('cancel')
    await job.moveToFailed(new Error('cancel'), '0', false)
  }, 3000)
}

test()

Backtrace:

Error: Missing lock for job 14. moveToFinished

Any hints/comments would be appreciated, thanks.

PDB6912 avatar Jul 11 '24 03:07 PDB6912