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
unexpected behaviour of R.once if the wrapped function throws an error. #3093
Comments
I definitely think it's right for I can see the benefit for capturing and rethrowing the error each time. Would you be interested in opening a PR? |
@Bradcomp sure, I’ll submit a PR tomorrow. |
@adrian-gierakowski: Are you still interested in creating a PR? |
Yes, I’ve got an implementation ready. |
Great! Feel free to post a PR with it. We're trying to clean up all sorts of old issues on the way to getting v1.0 out the door. |
Oh, v1 finally. Nice! |
We're trying... finally! |
Currently, if during first call the wrapped function throws an error and the error is handled, each subsequent call will return undefined.
This is due to the fact that
called
is set to true before the function is called:ramda/source/once.js
Lines 31 to 32 in ed191e6
Consider this example:
We are going to end up with
.then
callback being called withundefined
insteadcatch
callback being called with an error.I think the most reasonable behaviour would be for
R.once
to store the error which happens during the first call and re-throw it on each subsequent call.An alternative would be to swap the two lines of code quoted at the top of this message, but that would cause the
wrappedFunc
to be called multiple times, which breaks the expectation that it should only be ever calledonce
.The text was updated successfully, but these errors were encountered: