question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Why is asyncFilter calling asyncBatch

See original GitHub issue

The call to asyncBatch seems to be there in order to provide concurrency, but batch does not provide any concurrency, it just delays the emission of results until more results are ready. This sucks! If you try to consume only a single result from asyncFilter with a concurrency higher than 1, it will never return! It’ll just sit there waiting for more items to put in its batch! Why would we sacrifice the correctness of the implementation for a perf optimization that we don’t even know we need, and clearly don’t know how to properly test?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
conartist6commented, Jan 31, 2019

I have an even better approach that is almost ready to go which should actually be optimal and correct in every case.

0reactions
sithmelcommented, Jan 31, 2019

I like this approach. you could leverage Promise.race, when the buffer is full.

In my use case I had a stream of ids and I need to retrieve data from a rest endpoint for every id. So calling these endpoints in parallel gave a great perf boost. (I am talking about asyncMap, but asyncFilter behaves the same)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Call async/await functions in parallel - Stack Overflow
Original answer:​​ This answer is much more clear than Haven's. It's clear that the function calls will return promise objects, and await will...
Read more >
Deeply Understanding JavaScript Async and Await with ...
An async function always returns a promise.​​ The function fn returns 'hello' . Because we have used async , the return value 'hello'...
Read more >
Async and Batch Requests - Marketing API
The status param is used to filter requests by its own status and can be any combination ... You can make an async...
Read more >
How to use async functions with Array.filter in Javascript
While an async filter is possible, it works in a way that looks strange at first. And while concurrency controls are still available,...
Read more >
Vue Data Grid: Client-Side Data - High Frequency Updates
The default wait between executing batches is 50ms. This means when an Async Transaction is provided to the grid, it can take up...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found