Skip to content
Permalink
Browse files

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 <benjamingr@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
  • Loading branch information...
addaleax committed Jul 11, 2019
1 parent 35cb955 commit 779a05d5d1bfe2eeb05386f6415d36f80ca0b3b5
Showing with 2 additions and 0 deletions.
  1. +2 −0 lib/_http_server.js
@@ -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

0 comments on commit 779a05d

Please sign in to comment.
You can’t perform that action at this time.