-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
Provide custom onError handler for http-proxy-middleware #502
Conversation
This error message looks very confusing and aggressive. Can we improve the error output of this Node module first, to be readable in common cases? |
Personally I think the error message (as is) might still be better than being silent. It gives some hints, such as keyword "Proxy Error", standard POSIX error code, and the hostname and targetUri the proxy failed to access. However I totally understand the concern and CRA's principled approach of being beginner friendly. I looked into how the error messages (with error codes such as ECONNREFUSED) is formulated:
So as @gaearon suggested, the straightforward approach may be to improve the error output in http-proxy-middleware (or http-proxy). The logError implementation can simply reference the NodeJS common System Error page (as a link), and/or print out the plain text explanations mapped to the common errors such as ECONNREFUSED, ECONNRESET, and ETIMEDOUT. |
Errno is a cool npm package for the purpose of translating node's errors |
Sounds good to me, would you like to send a PR to |
Yes I can do a PR to http-proxy-middleware. So we can either
Any preference? |
We decided to update this to use |
@gaearon Yes we decided to use onError. Just got around to implement it. Two options with slight differences. 2 Cyan color for url and links: Any preference? I will check in code later on. |
Let’s make it |
Hmm. It’s still a bit too easy to miss it. Maybe try |
This looks good. |
Let’s do the second one. I would probably remove cyan from Node docs link and maybe add cyan to the error code instead. Also could try putting the whole second line into |
Beautiful work. Thanks. |
Out in 0.4.1! |
* Change http-proxy-middleware logLevel from silent to error * provide onError handler for httpProxyMiddleware
* Change http-proxy-middleware logLevel from silent to error * provide onError handler for httpProxyMiddleware
http-party/node-http-proxy#579 Look at this issue! |
This will change the http-proxy-middle logLevel option from 'silent' to 'error' in development mode.
Errors are bound to occur when proxying API requests to an API server during development, for various reasons such as forgetting to start the API server or using an incorrect port. With 'silent' option, no error message will be shown in the command line console at all, which can be confusing. With 'error' option, the console will show a very concise and informative error message, which helps to quickly pinpoint to the issues.
For example, following is an example of the error message (caused by not starting the API server) in the command line console: