bottleneck icon indicating copy to clipboard operation
bottleneck copied to clipboard

Need help applying multiple limiters

Open viktorgullmark opened this issue 4 years ago • 0 comments

Hey, didnt know where to turn exactly but I didnt see this covered in the docs.

I want to comply to the following headers: x-rate-limit: 15:10:60,30:300:300.

I have tried doing so by setting up the following and chaining them:

const limiter1 = new Bottleneck({ reservoir: 30, reservoirRefreshAmount: 30, reservoirRefreshInterval: 300 * 1000, maxConcurrent: 1, minTime: 500, });

const limiter2 = new Bottleneck({ reservoir: 15, reservoirRefreshAmount: 15, reservoirRefreshInterval: 10 * 1000, maxConcurrent: 1, minTime: 500, });

const chained = limiter1.chain(limiter2);

Since I create these at the same time, the reservoirRefreshInterval keeps ticking for the second limiter when its stuck waiting on the first one, so in theory too many requests could be sent in a shorter timespan.

Is there any way of complying to multiple limits like this?

Thanks

viktorgullmark avatar Oct 12 '21 22:10 viktorgullmark