mirror of
https://github.com/vitejs/vite.git
synced 2024-11-22 07:09:05 +00:00
fix: close socket when client error handled (#9816)
This commit is contained in:
parent
05b3ce6aa7
commit
ba62be40b4
@ -190,7 +190,9 @@ export function setClientErrorHandler(
|
||||
logger: Logger
|
||||
): void {
|
||||
server.on('clientError', (err, socket) => {
|
||||
let msg = '400 Bad Request'
|
||||
if ((err as any).code === 'HPE_HEADER_OVERFLOW') {
|
||||
msg = '431 Request Header Fields Too Large'
|
||||
logger.warn(
|
||||
colors.yellow(
|
||||
'Server responded with status code 431. ' +
|
||||
@ -198,5 +200,9 @@ export function setClientErrorHandler(
|
||||
)
|
||||
)
|
||||
}
|
||||
if ((err as any).code === 'ECONNRESET' || !socket.writable) {
|
||||
return
|
||||
}
|
||||
socket.end(`HTTP/1.1 ${msg}\r\n\r\n`)
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user