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 stuck halfOpen when using errorFilter #389

Merged
merged 5 commits into from
Dec 17, 2019
Merged

Conversation

jairelton
Copy link
Contributor

Fix issue #388

Copy link
Member

@lance lance left a comment

Choose a reason for hiding this comment

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

I appreciate the PR - thanks! But I'm not sure about the implementation. See code comments...

test/half-open-test.js Outdated Show resolved Hide resolved
test/half-open-test.js Outdated Show resolved Hide resolved
lib/circuit.js Outdated Show resolved Hide resolved
Jair Batista and others added 2 commits December 2, 2019 19:33
When an error is filtered by an errorFilter the request is
considered neither success nor failure, leaving the circuit
in an inconsistent state. This fixes that issue by emitting
success event when the error is filtered.
@lance lance self-requested a review December 2, 2019 22:55
Copy link
Member

@lance lance left a comment

Choose a reason for hiding this comment

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

Please add a test (or assertion) that a fallback function was not called even if the circuit has one.

lib/circuit.js Show resolved Hide resolved
When an error is filtered, it is considered a success, so the fallback
function should not be used. In that case the circuit would return the
error as returned by the underlying service.
@lance
Copy link
Member

lance commented Dec 5, 2019

@jairelton thanks for making the change. In reviewing it, I realized that past behavior has been that, whether or not the error is filtered, fallback() is called. And if that call succeeds, then a resolved promise is returned. If not, a rejected promise is returned.

What I have suggested you do is changing the the behavior, and now I am having second thoughts about it because this would really be a semver-major change, I think. @lholmquist do you have any thoughts on this?

@lance
Copy link
Member

lance commented Dec 11, 2019

@lholmquist do you mind taking a look and letting me know what you think?

@lholmquist lholmquist self-requested a review December 12, 2019 02:36
lib/circuit.js Outdated Show resolved Hide resolved
When an error is filtered, it is considered a success, however we need a
result to resolve with, this way, we should call fallback to get a valid
result. If there is no fallback, we reject to give the application a
chance to handle the error.
@lance
Copy link
Member

lance commented Dec 17, 2019

@lholmquist I'm going to land this for now, but let's keep an eye on how filters/fallbacks are used going forward.

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.

3 participants