bullmq icon indicating copy to clipboard operation
bullmq copied to clipboard

worker.getNextJob timeout

Open y-nk opened this issue 10 months ago • 2 comments

Is your feature request related to a problem? Please describe.

The current worker.getNextJob is either blocking (default) or non-blocking. the problem is that the blocking version does not have a configurable timeout to release the lock. if we await for this, it'll be forever

Describe the solution you'd like a timeout option for when block is true

Describe alternatives you've considered passing block: false and harassing the server in a loop with await setTimeout in between to tame the worker

y-nk avatar Feb 06 '25 19:02 y-nk

There is actually a timeout which is by default 10 seconds: https://api.docs.bullmq.io/interfaces/v5.WorkerOptions.html#drainDelay

manast avatar Feb 07 '25 14:02 manast

@manast i would expect that it should rather be a local timeout setting in the 2nd param of getNextJob. for example:

getNextJob: (blockingUntil: number | false = 10_000) => Promise<Job | undefined>

that is: call is blocking by default, timeout at 10s. you can pass a different number to set the timeout locally, or false for non blocking (or 0 maybe, but less intuitive)

y-nk avatar Feb 11 '25 10:02 y-nk