Passing doNotWaitActive=true to queue.pause means queue won't actually be paused
Created by: gabegorelick
Description
queue.pause
has an option called doNotWaitActive
. I believe the intention is that when this is set to true
, pause
will not wait for any active jobs to finish before resolving. But I would still expect no new jobs to be processed.
Internally, doNotWaitActive=true
means pause
will not call whenCurrentJobsFinished
. But whenCurrentJobsFinished
is where we stop polling for new jobs: https://github.com/OptimalBits/bull/blob/146bc8ed4341ec3e54b299c22e60dc3267d8b6d1/lib/queue.js#L1176-L1178
Thus, without calling whenCurrentJobsFinished
, the queue isn't really paused: a job added after queue.pause(true, true)
will be processed.
Minimal, Working Test code to reproduce the issue.
queue.process(job => { throw new Error('Job should not be processed'); });
// I don't want to process any more jobs,
// but I want to let any active jobs finish without waiting for them
await queue.pause(true, true);
await queue.add('foo', {});
Bull version
3.11.0