Obliterate!

Obliterate!

I never though I would even create a piece of code that "obliterates" anything, but here it is anyway!

I just released a new method for Bull/BullMQ to "obliterate" your queues. The name is chosen so that it is used carefully, since this will indeed completely destroy your queue leaving no traces of its existence.

await myQueue.obliterate();

The method is unfortunately not atomic since removing all the keys part of a key can be a lengthy process depending on how many jobs you have in your queues.

As soon as you call the method the queue will globally paused, by default it will fail if there are currently any active jobs, this is to prevent possible side effects by workers that suddenly will find that the job they are working on no longer exists.

The method will remove in chunks of maximum 5000 keys, but since it is not atomic, side-effects could leave the queue half deleted. For example, if the queue is unpaused  by another script while this method is running, it will fail with an exception.

Anyway, you asked for this so here it is, but use with care!.



Follow me on twitter if you want to be the first to know when I publish new tutorials and tips for Bull/BullMQ.

And remember, subscribing to Taskforce.sh is the greatest way to help supporting future BullMQ development!