xavi- / node-simple-rate-limiter

A simple way to rate limit how often a function is executed.
76 stars 10 forks source link

Wait for response? #9

Open Zebusch opened 6 years ago

Zebusch commented 6 years ago

Hi! We are making request towards and API that throttles if there are more than X requests at the same time. This pluing works great on "my machine", but if i run it on a cloud service that's a bit more slow, i can end up in a situation where it does in fact not make more requests that i have specified. The problem is if the requests take some time to get response from. So the rate limiter dispatches the calls within the limits but since there are still requests pending, the API starts to throttle.

Is there something i can do to make the limiter also keep track of if the requests are "done" or not?

Revadike commented 6 years ago

maybe making the function synchronic with Promises and await might work?