Skip to content
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

fix: return error from invocation when error filter filtered errors #567

Merged
merged 1 commit into from Apr 15, 2021

Conversation

lance
Copy link
Member

@lance lance commented Apr 15, 2021

This commit reverts some of the behavior changes in
#556. In that PR, the intent
was to avoid calling the fallback function when an an invocation error
is filtered by a user supplied errorFilter function. It did
accomplish that, however, it also changed how a function resolves
in the case of a filtered error. Previously, even though the error
was filtered, the function invocation would return the error to the
caller. With #556, this changed so that the caller instead receives
simply a truthy value.

This commit reverts that behavior so that the error is returned.

While it may seem counter intuitive to return an error when the it
was filtered by a user supplied errorFilter function, there are good
reasons to do so. It provides the caller with error information at the
point of invocation instead of in an event listener which may be
disconnected from the invocation code path.

The purpose of errorFilter is simply to prevent filtered errors from
causing the circuit to open. But the fact is that the function invocation
failed, and providing this to the user at the point of failure is better
usability in my opinion.

Plus, it's what we've always been doing, and I think the change to returning
a truthy value was really just a side effect of not calling the fallback
function. My preference would be to minimize the breaking changes in 6.x,
and this PR helps to accomplish that (albeit 6.0 will be a weird bump in
the road).

Fixes: #564

Signed-off-by: Lance Ball lball@redhat.com

This commit reverts some of the behavior changes in
nodeshift#556. In that PR, the intent
was to avoid calling the fallback function when an an invocation error
is filtered by a user supplied `errorFilter` function. It did
accomplish that, however, it also changed how a function resolves
in the case of a filtered error. Previously, even though the error
was filtered, the function invocation would return the error to the
caller. With nodeshift#556, this changed so that the caller instead receives
simply a truthy value.

This commit reverts that behavior so that the error is returned.

While it may seem counter intuitive to return an error when the it
was filtered by a user supplied `errorFilter` function, there are good
reasons to do so. It provides the caller with error information at the
point of invocation instead of in an event listener which may be
disconnected from the invocation code path.

The purpose of `errorFilter` is simply to prevent filtered errors from
causing the circuit to open. But the fact is that the function invocation
failed, and providing this to the user at the point of failure is better
usability in my opinion.

Plus, it's what we've always been doing, and I think the change to returning
a truthy value was really just a side effect of not calling the fallback
function. My preference would be to minimize the breaking changes in 6.x,
and this PR helps to accomplish that (albeit 6.0 will be a weird bump in
the road).

Fixes: nodeshift#564

Signed-off-by: Lance Ball <lball@redhat.com>
@lance lance requested a review from a team April 15, 2021 21:29
@lance lance self-assigned this Apr 15, 2021
@lance
Copy link
Member Author

lance commented Apr 15, 2021

Note that even though this is a breaking change from 6.0 behavior, I think the change introduced in #564 should not have had the effect it did on circuit return values (and I know, I reviewed and signed off on that PR). Therefore, I don't think this should be a major version bump. In fact, I think it should probably be patch level.

Copy link
Member

@lholmquist lholmquist left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That explanation does make sense. And yea, this can just be a patch or minor release

@lance lance changed the title fix: return errors from invocation filtered errors fix: return error from invocation when error filter filtered errors Apr 15, 2021
@lance
Copy link
Member Author

lance commented Apr 15, 2021

I cannot figure out the best title for this PR! It's like a tongue twister with recursion. An Escher-like PR title.

@lholmquist lholmquist merged commit 737e1b1 into nodeshift:main Apr 15, 2021
@lance lance deleted the lance/564-error-handling branch April 16, 2021 12:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Current behavior of the errorFilter option
2 participants