-
Notifications
You must be signed in to change notification settings - Fork 14
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
Error handling explanation is not clear #18
Comments
You are correct. This code block’s comment contains a typo due to copying and pasting. Array.fromAsync will not return a rejecting promise in this case. I will fix this.
This code block also contains typos, which I need to fix. I had forgotten to include a setTimeout-based delay on the zeroth item, as in your own example. I will fix this, too. Thanks for reporting these errors! |
Closes #18. See also #16. Co-authored-by: Jordan Harband <[email protected]>
Closes #18. See also #16. Co-authored-by: Jordan Harband <[email protected]>
I've read #16, and I think I understand and agree with the conclusions that it came to. This is an issue I have with the explanation in the README that was added after closing that issue.
Specifically, this example makes no sense to me:
How can
.fromAsync
ever reject if the function never yields a rejecting promise? The namerejection
makes it look like it should reject, but the error was already caught and discarded byconsole.error
.The surrounding text doesn't help explain much:
If the goal is to warn that multiple already-created promises that end up rejecting in the input will lead to an uncaught promise exception, then I think it'd be best to just say that. Because
Array.fromAsync
will handle the first rejection it sees, if only to pass it up and stop further iteration.When it comes to
Promise.all
, I think I understand this part:I interpreted it as "
Promise.all
might reject with an error from any of the promises, because it eagerly looks ahead". The code sample following it doesn't seem to demonstrate that, though. It has the exact same outcome as the initialArray.fromAsync
example (without the.catch(console.error)
)Both of these handle
rejection
, and no uncaught rejection error will happen (excluding the output promises).As far as I can tell the only actual differences in error handling between the two are that
Array.fromAsync
always checks each item in order, and will stop on the first rejection (meaning it will not catch any rejections past the first one). I think an explanation like this could suffice:The text was updated successfully, but these errors were encountered: