-
Notifications
You must be signed in to change notification settings - Fork 131
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
Handle store backend errors #325
Conversation
097b1c4
to
c6f7cea
Compare
@minrk I find it very hard to review in CHP =/ Can you help out on this? |
to ensure it returns a promise, no matter where errors may occur
lib/configproxy.js
Outdated
target: route.data.target, | ||
}; | ||
} | ||
return new Promise((resolve, reject) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noting for review:
wrapping this in a promise ensures that targetForReq always returns a Promise, even if routes.getTarget
raises directly (as opposed to returning a failing promise).
.catch(function (e) { | ||
if (res.finished) throw e; | ||
that.handleProxyError(500, kind, req, res, e); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These lines are the only changes in this function: adding the catch. prettier chooses a different indentation when there's both a .then
and a .catch
, which makes this PR look bigger than it is.
I got the following error with https://github.com/globocom/configurable-http-proxy-redis-backend when I hit a URL like
http://chp.example.com/%25
. Furthermore, the client didn't get a response forever.Although this error should be taken care of by the store backend, CHP should make a response at least.