p-queue
p-queue copied to clipboard
Throw error if exceeding x amount of items, stop queue
What's the use-case? Where exactly should it throw? queue.add? Would be useful if you could elaborate a bit more on what you need and why.
I generate a large queue of cache rebuilding jobs, I'm a little scared that if I throw too many at it, it may freak out. The jobs aren't critical so can be discarded if there's too many. I'm just worried about memory bloat. Maybe measuring the queue's memory is more accurately what I'm concerned about.
You can do this yourself, like if(queue.pending) throw new Error() else queue.add(() => ,,,)