-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Also forward error requests to the proxy #2425
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2425 +/- ##
==========================================
+ Coverage 93.8% 93.81% +<.01%
==========================================
Files 34 34
Lines 1307 1309 +2
Branches 371 371
==========================================
+ Hits 1226 1228 +2
Misses 79 79
Partials 2 2
Continue to review full report at Codecov.
|
|
||
this.app.use(handle); | ||
// Also forward error requests to the proxy so it can handle them. | ||
this.app.use((error, req, res, next) => handle(req, res, next)); |
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.
It is create two instances of proxy that was reduce performance
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.
The proxy middleware is created once, outside of handle
:
proxyMiddleware = getProxyMiddleware(proxyConfig);
… and the result is used in handle
on each request, be it a non-error or error request. So I don't think this change will hurt performance in any way.
If you really think this will hurt performance, are you able to provide an example to demonstrate that's the case?
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.
Each request now run handle
(
webpack-dev-server/lib/Server.js
Line 291 in 29a822e
const handle = (req, res, next) => { |
webpack-dev-server/lib/Server.js
Line 318 in 29a822e
return proxyMiddleware(req, res, next); |
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.
I don't believe that's true. handle
will only run once:
- If the request has not errored,
handle
will be called viaapp.use(handle)
. - If the request has errored,
handle
will be called viaapp.use((error, req, res, next) => handle(req, res, next))
.
You can see this for yourself if you add some logging to handle
.
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.
Hm, looks you are right https://expressjs.com/en/guide/error-handling.html
Something broken on CI, I rerun tests |
Bit thanks, sometimes I get too much error flow, and do not have time to investigate them in detail, I apologize for the situation and am very glad that you yourself could find the problem and fix it |
@evilebottnawi No problem, thanks for reviewing my PR! 😄 |
Fixes #2380
For Bugs and Features; did you add new tests?
Yes
Motivation / Use-Case
See #2380 and #2380 (comment).
Breaking Changes
Additional Info