Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

forEachLimit is ignoring the concurrent paramter #5

Closed
Aminadav opened this issue Oct 20, 2021 · 1 comment · Fixed by #6
Closed

forEachLimit is ignoring the concurrent paramter #5

Aminadav opened this issue Oct 20, 2021 · 1 comment · Fixed by #6
Labels
bug Something isn't working

Comments

@Aminadav
Copy link

See this Code:

//@ts-ignore
var {forEachLimit}=require('modern-async')

var ar=[]
for(let i=0;i<=100;i++) ar.push(i)

forEachLimit(ar,async item=>{
  await delay(1000)
  console.log(item)
},5)
function delay(ms){return new Promise(resolve=>setTimeout(resolve,ms))}

It should show every 1 seconds 5 items. But it shows after 1 second all the items.
I found the bug and I wanted to fix it:

In the file forEachLimit.js:

async function forEachLimit (iterable, iteratee, concurrency) {
  await mapLimit(iterable, async (v, i, t) => {
    iteratee(v, i, t)
  }, concurrency)
}

missing await before iteratee(v, i ,t)

I wanted to fix it but the current version in GitHub is different (in development).
Can you provide hotfix and publish it to NPM as 1.0.4?
It's really a security issue for servers to handle too many requests at the same time.

By the way, thank you for you awesome library.

@Aminadav Aminadav added the bug Something isn't working label Oct 20, 2021
@nicolas-van nicolas-van mentioned this issue Oct 20, 2021
@nicolas-van
Copy link
Owner

Version 1.0.4 has been published with the fix.

Thank you for reporting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants