p-queue icon indicating copy to clipboard operation
p-queue copied to clipboard

Throw error if exceeding x amount of items, stop queue

Open jpike88 opened this issue 5 years ago • 3 comments

jpike88 avatar Mar 02 '20 08:03 jpike88

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.

sindresorhus avatar Mar 06 '20 18:03 sindresorhus

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.

jpike88 avatar Mar 08 '20 15:03 jpike88

You can do this yourself, like if(queue.pending) throw new Error() else queue.add(() => ,,,)

dobesv avatar Mar 26 '21 23:03 dobesv