We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent bf51ed4 commit 4848e41Copy full SHA for 4848e41
1 file changed
packages/vite/src/node/server/middlewares/proxy.ts
@@ -52,8 +52,17 @@ export function proxyMiddleware(
52
53
proxy.on('error', (err, req, originalRes) => {
54
// When it is ws proxy, res is net.Socket
55
- const res = originalRes as http.ServerResponse | net.Socket
56
- if ('req' in res) {
+ // originalRes can be falsy if the proxy itself errored
+ const res = originalRes as http.ServerResponse | net.Socket | undefined
57
+ if (!res) {
58
+ config.logger.error(
59
+ `${colors.red(`http proxy error: ${err.message}`)}\n${err.stack}`,
60
+ {
61
+ timestamp: true,
62
+ error: err,
63
+ },
64
+ )
65
+ } else if ('req' in res) {
66
config.logger.error(
67
`${colors.red(`http proxy error at ${originalRes.req.url}:`)}\n${
68
err.stack
0 commit comments