Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixup! http: reset parser.incoming when server request is finished
  • Loading branch information
addaleax committed Aug 24, 2019
commit 6232470fa0deb756ce1c654a1ee9433e878b64ba
8 changes: 5 additions & 3 deletions lib/_http_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -611,13 +611,15 @@ function onParserExecuteCommon(server, socket, parser, state, ret, d) {
}
}

function clearIncoming(parser, req) {
function clearIncoming(req) {
req = req || this;
const parser = req.socket && req.socket.parser;
// Reset the .incoming property so that the request object can be gc'ed.
if (parser && parser.incoming === req) {
if (req.readableEnded) {
parser.incoming = null;
} else {
req.on('end', clearIncoming.bind(null, parser, req));
req.on('end', clearIncoming);
}
}
}
Expand All @@ -629,7 +631,7 @@ function resOnFinish(req, res, socket, state, server) {
assert(state.incoming.length === 0 || state.incoming[0] === req);

state.incoming.shift();
clearIncoming(socket.parser, req);
clearIncoming(req);

// 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