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

Send proper error response upon proxy error #588

Merged
merged 5 commits into from
Sep 5, 2016
Merged

Conversation

cloudmu
Copy link
Contributor

@cloudmu cloudmu commented Sep 5, 2016

Currently the custom onError handler for httpProxyMiddleware only logs proxy error on the console (#502). This amends the onError handler so it will also send proper error response to the client.

Otherwise the client will wait for the response and eventually timeout with ERR_EMPTY_RESPONSE, instead of the proper proxy error. See two screenshots before/after this PR.

  1. No proper error response (timeout after up to 2 min):
    noerrorreponse

  2. Proper error response (with this PR):
    immediate500reponse

    Note the error response to the client also mirrors the error logged on the dev console:
    Proxy error: Could not proxy request /api/login from localhost:3000 to http://localhost:3001 (ECONNREFUSED).

@ghost ghost added the CLA Signed label Sep 5, 2016
@gaearon gaearon added this to the 0.4.2 milestone Sep 5, 2016
@gaearon gaearon merged commit 29107ca into facebook:master Sep 5, 2016
@gaearon
Copy link
Contributor

gaearon commented Sep 5, 2016

Thanks!

@cloudmu cloudmu changed the title Send proper error response in custom onError handler for httpProxyMiddleware. Send proper error reponse upon proxy error Sep 6, 2016
stayradiated pushed a commit to stayradiated/create-react-app that referenced this pull request Sep 7, 2016
…dleware. (facebook#588)

* Change http-proxy-middleware logLevel from silent to error

* provide onError handler for httpProxyMiddleware

* Send proper error reponse upon proxy error.
@cloudmu cloudmu changed the title Send proper error reponse upon proxy error Send proper error response upon proxy error Sep 11, 2016
@gaearon gaearon mentioned this pull request Sep 18, 2016
@gaearon
Copy link
Contributor

gaearon commented Sep 18, 2016

This should be fixed in 0.4.2.
Please verify!

@cloudmu
Copy link
Contributor Author

cloudmu commented Sep 18, 2016

Yes, works as expected.

feiqitian pushed a commit to feiqitian/create-react-app that referenced this pull request Oct 25, 2016
…dleware. (facebook#588)

* Change http-proxy-middleware logLevel from silent to error

* provide onError handler for httpProxyMiddleware

* Send proper error reponse upon proxy error.
@lock lock bot locked and limited conversation to collaborators Jan 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants