DJWassink / Promise-parallel-throttle

It's kinda like Promise.all(), but throttled!
MIT License
81 stars 3 forks source link

Warnings when maxInProgress > tasks.length #12

Closed travellingprog closed 7 years ago

travellingprog commented 7 years ago

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).

DJWassink commented 7 years ago

Good catch! Fix incoming.

monolithed commented 7 years ago

The same problem

DJWassink commented 7 years ago

Should be fixed in version 2.3.0 🎉

travellingprog commented 7 years ago

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!

DJWassink commented 7 years ago

Awesome, glad you like it 👍