Skip to content

Commit

Permalink
fix(proxy): handle error when proxy itself errors
Browse files Browse the repository at this point in the history
  • Loading branch information
chaejunlee committed Jul 23, 2023
1 parent 06e4f57 commit befb2af
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/vite/src/node/server/middlewares/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ export function proxyMiddleware(
}

proxy.on('error', (err, req, originalRes) => {
// originalRes can be falsy if the proxy itself errored
if (!originalRes) {
httpServer?.emit('error', err)
}
// When it is ws proxy, res is net.Socket
const res = originalRes as http.ServerResponse | net.Socket
if ('req' in res) {
Expand Down

0 comments on commit befb2af

Please sign in to comment.