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
Wait to call error callback until currently running parallel tasks complete #51
Comments
Thumbs up for this. One more scenario: we have a parallel execution of several backend requests via http. When writing this queue I already know, that data from these requests isn't mandatory for the application in common. An app would, of course, gracefully degrade, but will still work. Current option is to handle such errors in methods, that do such requests, and then pass null as the first argument for the callback. It isn't very convinient. It would be very nice, if I could pass an option to the async to tell it, that I want all tasks to finish even if there were errors. |
Anyone? |
Really want this feature for async.series, async.foreach and async.auto too! |
I want this too. A callback should be called after all tasks are completed, even if any of them failed. |
Plus one as well on this issue, our use case: Need to try and get information from x amount of different sources, all independent, perfect for parallel, except if one task errors the main call back is called, but after the other x-1 tasks finish the main callback is not called. I would still like to get the information i did get back but since the main call back is never called again after all tasks complete if an error has been thrown i can't get the information available. If we can wait until all the tasks finish to call the main call back so err an array as well that would be perfect |
Yes, certainly a valid use case. I'm going to work on an API that will do this and various other tweaks for all functions in the near future. |
I'm going to guess you didn't get to this? Still worth doing? |
This message was created automatically by mail delivery software. A message that you sent could not be delivered to one or more of its alizbazar@gmail.com ------- This is a copy of the message, including all the headers. ------ ----==_mimepart_5335ae2b48ba_24333fd1fcd332b418146a Closed #51. Reply to this email directly or view it on GitHub: Closed #51. — ----==_mimepart_5335ae2b48ba_24333fd1fcd332b418146a-- |
This default behavior has caused us headaches as well. This feature request was closed, is it in the pipeline or is it just discarded? |
|
I won't be changing the default behaviour of async.parallel any time soon - but I understand why this would be needed. Open to other suggestions. |
Use case: I have some parallel tasks that writes files to a temporary directory, and I want a cleanup function to delete the temporary directory after all tasks complete. If one task fails, I'd like to delete the directory immediately.
async.parallel
fits the bill perfectly, except that I need to wait to delete the directory until all currently running parallel tasks complete, lest the other running tasks try to write files to a nonexistent directory.I imagine this is a pretty common scenario, and it's rather tricky to do without resorting to running the tasks serially. (Perhaps there's an easy way to do it that I haven't thought of -- would love to hear that.)
It would be useful if, for any parallel tasks,
async
waited to call the callback function in the case of errors until all concurrently running tasks complete. That is, once a task calls its callback with an error,async
should stop starting new tasks and run the final callback once the number of running tasks reaches zero.The text was updated successfully, but these errors were encountered: