0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00

http: reset parser.incoming when server response is finished

This resolves a memory leak for keep-alive connections with a naïve
approach.

Fixes: https://github.com/nodejs/node/issues/9668

PR-URL: https://github.com/nodejs/node/pull/28646
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit is contained in:
Anna Henningsen 2019-07-12 00:32:21 +02:00
parent 35cb955865
commit 779a05d5d1
No known key found for this signature in database
GPG Key ID: 9C63F3A6CD2AD8F9

View File

@ -621,6 +621,8 @@ function resOnFinish(req, res, socket, state, server) {
assert(state.incoming.length === 0 || state.incoming[0] === req);
state.incoming.shift();
// Reset the .incoming property so that the request object can be gc'ed.
if (socket.parser) socket.parser.incoming = null;
// If the user never called req.read(), and didn't pipe() or
// .resume() or .on('data'), then we call req._dump() so that the