Request hangs when its request header size exceeds
nigelis opened this issue · comments
Nigel Li commented
- Used appropriate template for the issue type
- Searched both open and closed issues for duplicates of this issue
- Title adequately and concisely reflects the feature or the bug
Restify Version: v8.5.2
Node.js Version: v16.13.2
Expected behaviour
Response with status code 400 Bad Request
or 431 Request Header Fields Too Large
.
Actual behaviour
The request hangs without any response.
Repro case
const server = restify.createServer();
// Uncomment, then it is responded with status code 431 for request with too large headers.
// server.server.removeAllListeners('clientError');
server.get('/api', (req, res, next) => { res.send(200); next(); });
server.listen(8080);
Request with lots of large headers, the total size exceeds 16KB.
Cause
Restify forwards several events from the internal server
to itself.
Lines 144 to 151 in 5c7eb95
Lines 204 to 206 in 5c7eb95
Forwarding the event clientError
breaks the error handling of the internal server
, thus the request hangs.
- https://github.com/nodejs/node/blob/fdab137e6459b9ea40c6f8ab234d39d777be91f7/lib/_http_server.js#L662-L687
- https://nodejs.org/api/http.html#event-clienterror
Are you willing and able to fix this?
Yes.
Because no event listener for clientError
is added by default, it is OK to not forward the event.