Use this file to discover all available pages before exploring further.
BullMQ does not provide a specific mechanism to timeout jobs, however this can be accomplished in many cases with a custom timeout code in the worker’s process function.
The basic concept is to set up a timeout callback that will abort the job processing, and throw an UnrecoverableError to avoid retries:
const worker = new Worker('foo', async job => { let controller = new AbortController(); const timer = setTimeout(() => controller.abort(), job.data.timeout); try { await doSomethingAbortable(controller.signal); } catch(err) { if (err.name == "AbortError") { throw new UnrecoverableError("Timeout"); } else { throw err; } } finally { clearTimeout(timer); }});
Note how we specified the timeout as a property of the job’s data, in case we want to have different timeouts depending on the job. You could also use a fixed constant timeout for all jobs.
While it is possible to implement timeout in your jobs, the mechanism to do it may vary depending on the type of asynchronous operations your job is performing. In many cases, using AbortController in combination with a setTimeout is more than enough.