Skip to content

Commit 779a05d

Browse files
committed
http: reset parser.incoming when server response is finished
This resolves a memory leak for keep-alive connections with a naïve approach. Fixes: #9668 PR-URL: #28646 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent 35cb955 commit 779a05d

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

lib/_http_server.js

+2
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,8 @@ function resOnFinish(req, res, socket, state, server) {
621621
assert(state.incoming.length === 0 || state.incoming[0] === req);
622622

623623
state.incoming.shift();
624+
// Reset the .incoming property so that the request object can be gc'ed.
625+
if (socket.parser) socket.parser.incoming = null;
624626

625627
// If the user never called req.read(), and didn't pipe() or
626628
// .resume() or .on('data'), then we call req._dump() so that the

0 commit comments

Comments
 (0)