-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
async parallel error handling #334
Comments
+1. |
Just wrap these functions with your own functions that silently ignore/log errors. Real-world example: https://github.com/rlidwka/sinopia/blob/master/lib/storage.js#L161 . As you can see, that function never returns error as first argument. You can do the same. I don't see any problem here. |
+1 for the feature request. We've implemented a version which wraps async, called parallelCollect, which collects the errors into a dictionary that is passed to the final callback when all of the individual tasks have completed (in the same way as the successful results are passed if you give it named functions). With regards to @rlidwka's comment - It's not that it's hard to implement - it's just a use case that many people would be useful in the core async library. Don't mind doing the implementation myself via a pull request if it's not a waste of time. |
+1 |
Can be done with a wrapper, but the task is generic, should be a ready-to-use async method for it. |
+1. It makes sense to present errors in the same structure as the results. If 2 or more parallel callbacks throw errors, you only get the first error. Also, when the error is shown, you don't receive the results from the other successful callbacks. |
+1 |
It has been solved? Is now possible to collect errors of execute task regardless? |
Would love a better wrapper example in here / agreed upon solution. Bump 👍 |
Is this what you guys meant by wrapper?
Then within the call: |
+1 |
2 similar comments
👍 |
+1 |
How to continue *parallel* processing in case of a failing task seems to be a frequently asked question. It was mentioned in several issues: - caolan/async#334 - caolan/async#675 - caolan/async#798 - caolan/async#942 Adding a hint to the documentation might help users of the library to find out about the answer to this question.
When processing multiple functions in parallel, using async parallel, if one of those functions throws an error via it's callback, async parallel processes it's callback before some of it's functions have completed. This may be the desired behaviour under some situations, however, I desire different logic. I would like all functions to run regardless of if some of them error or not, and then to be able to process through an error array after they have all completed processing.
My workaround for this situation currently is for my functions running in parallel to always not throw an error via normal way, but instead pretend they succeeded, and pass their error/data through an object in the result. In this way all of the functions will run, and then I have to manually process through the result objects looking for and handling any errors.
However, bypassing normal error handling in order to workaround async parallel isn't ideal in my mind. Perhaps there could be a better solution to provide either option for us, depending on the desired behaviour.
The text was updated successfully, but these errors were encountered: