Skip to content

Commit

Permalink
feat: less warning and more docs
Browse files Browse the repository at this point in the history
  • Loading branch information
sapphi-red committed Jul 29, 2022
1 parent 344aaae commit 45fcf23
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
11 changes: 11 additions & 0 deletions docs/guide/troubleshooting.md
Expand Up @@ -44,6 +44,17 @@ To solve this:
$ sudo sysctl fs.inotify.max_user_watches=524288
```

### 431 Request Header Fields Too Large

When the server / WebSocket server receives a large HTTP header, the request will be dropped and the following warning will be shown.

> Server responded with status code 431. See https://vitejs.dev/guide/troubleshooting.html#_431-request-header-fields-too-large.
This is because Node.js limits request header size to mitigate CVE-2018-12121.

To avoid this, try to reduce your request header size. For example, if the cookie is long, delete it.
Or you can use [`--max-http-header-size`](https://nodejs.org/api/cli.html#--max-http-header-sizesize) to change max header size.

## HMR

### Vite detects a file change but the HMR is not working
Expand Down
12 changes: 2 additions & 10 deletions packages/vite/src/node/http.ts
Expand Up @@ -191,18 +191,10 @@ export function setClientErrorHandler(
): void {
server.on('clientError', (err, socket) => {
if ((err as any).code === 'HPE_HEADER_OVERFLOW') {
if (!socket.writableEnded) {
socket.end(
'HTTP/1.1 431 Request Header Fields Too Large\r\n\r\n' +
'Request Header was too large. Node.js limits request header size. ' +
'Use https://nodejs.org/api/cli.html#--max-http-header-sizesize to change max header size.'
)
}
logger.warn(
colors.yellow(
'Server / WS server responded with "431 Request Header Fields Too Large." ' +
'Node.js limits request header size and the request was dropped. ' +
'Use https://nodejs.org/api/cli.html#--max-http-header-sizesize to change max header size.'
'Server responded with status code 431. ' +
'See https://vitejs.dev/guide/troubleshooting.html#_431-request-header-fields-too-large.'
)
)
}
Expand Down

0 comments on commit 45fcf23

Please sign in to comment.