Skip to content

Commit

Permalink
http: reset parser.incoming when server response is finished
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
addaleax committed Jul 28, 2019
1 parent 35cb955 commit 779a05d
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/_http_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 779a05d

Please sign in to comment.