Bull: timeout option not works as expected

Created on 4 Apr 2017  路  1Comment  路  Source: OptimalBits/bull

Hey

queue.add({
    id,
    url
  }, {
    attempts: 1,
    timeout: 5 * 1000,
    removeOnComplete: true,
    removeOnFail: true
  })

process file

module.exports = async function (job) {
  console.log('WAIT ', new Date() )
  await delay(20 * 1000)
  console.log('RESUME ', new Date())
  console.log('I dont expect to see this message')
}

It throws

TimeoutError: operation timed out
    at afterTimeout (/opt/node/savevideobot/downloader/node_modules/bluebird/js/release/timers.js:46:19)
    at Timeout.timeoutTimeout [as _onTimeout] (/opt/node/savevideobot/downloader/node_modules/bluebird/js/release/timers.js:76:13)
    at ontimeout (timers.js:365:14)
    at tryOnTimeout (timers.js:237:5)
    at Timer.listOnTimeout (timers.js:207:5)

But I expect it fails and doesn't continue after delay. am I right ?

Most helpful comment

not really. There is no way, that I am aware of, where a running function can be "cancelled". What happens is that the job is failed, but whatever is processing in the process function will continue to be executed.

In order to support real cancellation, other more advances approaches are needed, like using threads that can be killed if they exceed a given time etc. Check this issue: https://github.com/OptimalBits/bull/issues/479

>All comments

not really. There is no way, that I am aware of, where a running function can be "cancelled". What happens is that the job is failed, but whatever is processing in the process function will continue to be executed.

In order to support real cancellation, other more advances approaches are needed, like using threads that can be killed if they exceed a given time etc. Check this issue: https://github.com/OptimalBits/bull/issues/479

Was this page helpful?
0 / 5 - 0 ratings

Related issues

PhillippOhlandt picture PhillippOhlandt  路  4Comments

pintocarlos picture pintocarlos  路  3Comments

pigaov10 picture pigaov10  路  3Comments

NicolasDuran picture NicolasDuran  路  4Comments

adamsoffer picture adamsoffer  路  4Comments