Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
http: allow _httpMessage to be GC'ed
Set `socket._httpMessage` to `null` before emitting the `'connect'` or
`'upgrade'` event.
  • Loading branch information
lpinca committed Feb 19, 2018
commit c106d8006adf3d4d9790476069cc3bba882f4cf3
1 change: 1 addition & 0 deletions lib/_http_agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ function installListeners(agent, s, options) {
s.removeListener('close', onClose);
s.removeListener('free', onFree);
s.removeListener('agentRemove', onRemove);
s._httpMessage = null;
}
s.on('agentRemove', onRemove);
}
Expand Down
5 changes: 5 additions & 0 deletions test/parallel/test-http-connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ server.listen(0, common.mustCall(() => {
path: 'google.com:443'
}, common.mustNotCall());

req.on('socket', common.mustCall((socket) => {
assert.strictEqual(socket._httpMessage, req);
}));

req.on('close', common.mustCall());

req.on('connect', common.mustCall((res, socket, firstBodyChunk) => {
Expand All @@ -60,6 +64,7 @@ server.listen(0, common.mustCall(() => {
// Make sure this socket has detached.
assert(!socket.ondata);
assert(!socket.onend);
assert.strictEqual(socket._httpMessage, null);
assert.strictEqual(socket.listeners('connect').length, 0);
assert.strictEqual(socket.listeners('data').length, 0);

Expand Down