Skip to content

Commit

Permalink
fix: return 500 on proxy error only if possible (fixes #9172) (#9175)
Browse files Browse the repository at this point in the history
  • Loading branch information
sapphi-red authored Jul 17, 2022
1 parent e6f3b02 commit d2f02a8
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions packages/vite/src/node/server/middlewares/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,13 @@ export function proxyMiddleware(
error: err
}
)
res
.writeHead(500, {
'Content-Type': 'text/plain'
})
.end()
if (!res.writableEnded) {
res
.writeHead(500, {
'Content-Type': 'text/plain'
})
.end()
}
} else {
config.logger.error(`${colors.red(`ws proxy error:`)}\n${err.stack}`, {
timestamp: true,
Expand Down

0 comments on commit d2f02a8

Please sign in to comment.