I'm trying to pass next()
function to Bull job so I can handle asynchronous error handling with Express.
For some reason, it won't get forwarded.
This is is the route. data includes domain
and next()
which get passed to the Queue
crawler.post("/sitemap",async (req,res,next)=>{
const {domain} = req.body
const data = {domain,next}
const response = await generateSitemapQueue(data)
return res.json({message:`task has been added to the queue successfully...`,...response})
})
Queue simply adds data to the worker
sitemapQueue.process(createSitemapForDomain)
export const generateSitemapQueue = async (data) => {
sitemapQueue.add(data)
}
// Here next can still be accessible in data
Not at worker, next()
is undefined and cannot be called but domain is accessible. Why is that?
export const createSitemapForDomain = async (job,done)=>{
const {domain,next} = job.data
// next is undefined and cannot be called
}