Closed travellingprog closed 7 years ago
Good catch! Fix incoming.
The same problem
Should be fixed in version 2.3.0 🎉
Hey, just wanted to say thanks!
I was retouching the piece of my application code where I use Throttle today and finally made the upgrade to 3.0.0. Seems to be working great!
Awesome, glad you like it 👍
I'm using this library in a scenario where I don't know how many tasks I'm going to have. I've noticed that if the maxInProgress number I give happens to be bigger than tasks.length, I end up seeing a bunch of warnings in NodeJS
UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 8): TypeError: tasks[index] is not a function
After some investigation, I found that the issue is that on initialization,
nextTask()
is called maxInProgress times, regardless of the amount of tasks.Think this would be resolve if the initial loop's limit was set to
Math.min(maxInProgress, tasks.length)
.