Skip to content

Commit c9c7256

Browse files
addaleaxtargos
authored andcommitted
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 8db43b1 commit c9c7256

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

lib/_http_server.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,8 @@ function resOnFinish(req, res, socket, state, server) {
623623
assert(state.incoming.length === 0 || state.incoming[0] === req);
624624

625625
state.incoming.shift();
626+
// Reset the .incoming property so that the request object can be gc'ed.
627+
if (socket.parser) socket.parser.incoming = null;
626628

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

0 commit comments

Comments
 (0)