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 proxy errors #477
Handle proxy errors #477
Conversation
I couldn't really figure out how to test this with the testing setup. Any hint would be appreciated. |
@BigBlueHat anything I could do to move that one forward? |
In my case, It will fail and abort like this:
|
@BigBlueHat any chance looking into this? |
@patrikbeno figuring out a test case is easy, sure. What I would like to get help with is fitting this test in the testing env of the project. |
@indexzero ping? |
lib/http-server.js
Outdated
@@ -107,6 +107,14 @@ function HttpServer(options) { | |||
|
|||
if (typeof options.proxy === 'string') { | |||
var proxy = httpProxy.createProxyServer({}); | |||
proxy.on('error', function (err) { | |||
if (options.logFn) { // If there's a log function for requests we can log |
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.
If there's a log function set, the code should use that and not just console.info
. See https://github.com/indexzero/http-server/blob/94329688b5bf6c058a9f2c24739bd628b7345dce/lib/http-server.js#L62-L64
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.
Should I fake req
and res
arguments in this case? I don't have them in this context
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.
ping
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.
Move the on('error')
code into the before.push
https://github.com/indexzero/http-server/blob/f65f1a7154456f823261c4f8e90b35eff66eb23a/lib/http-server.js#L118 where the proxy is added into the mix.
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.
Found a cleaner way to do it. Force-pushed, please review 🙇
Any progress? @BigBlueHat crashing proxies is not cool |
f65f1a7
to
5d5de72
Compare
5d5de72
to
0b69655
Compare
Just a friendly reminder |
Just another friendly reminder @BigBlueHat |
Thank you 🙇 |
...y-error-handling Handle proxy errors Fixes #193
🎉 |
http-proxy
does not handle errors by default and would just throw crashing the server. This PR adds error handling with rudimental logging.