Problem with loading separate processors
Created by: artem-a
Description
When we set a separate processor without a file extension, we have no errors, but the processor does not work in version 3.4.2 (this is work in version 3.4.1).
Perhaps the system should throw an error message or load the processor without the file extension?
Minimal, Working Test code to reproduce the issue.
server.js
'use strict'
const path = require('path')
const Queue = require('bull')
const procPath = (...args) => path.resolve(__dirname, 'processors', ...args)
const blocksQueue = new Queue('blocks-queue')
blocksQueue.process('new-block', 20, procPath('blocks-new')) // works only for 3.4.1
// blocksQueue.process('new-block', 20, procPath('blocks-new.js'))
blocksQueue.on('completed', (job, result) => {
console.log('completed')
console.log(result)
})
process.on('SIGINT', () => {
blocksQueue.close()
process.exit(0)
})
console.log('start job server')
worker.js
'use strict'
const Queue = require('bull')
const blocksQueue = new Queue('blocks-queue')
blocksQueue
.on('global:completed', (jobId, result) => {
console.log('global:completed')
console.log(result)
})
setInterval(() => {
const data = { num: Math.random() }
const opts = { removeOnComplete: true }
blocksQueue.add('new-block', data, opts)
}, 2000)
process.on('SIGINT', () => {
blocksQueue.close()
process.exit(0)
})
processors/blocks-new.js
'use strict'
module.exports = async (job, done) => {
const result = await Promise.resolve(job.data.num)
done(null, { result })
}
Bull version
3.4.1, 3.4.2
Additional information
you need to run in separate terminals node server.js
& node worker.js