Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c7f9608

Browse filesBrowse files
lpincaaddaleax
authored andcommitted
http: allow _httpMessage to be GC'ed
Set `socket._httpMessage` to `null` before emitting the `'connect'` or `'upgrade'` event. PR-URL: #18865 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
1 parent 16ef386 commit c7f9608
Copy full SHA for c7f9608

File tree

Expand file treeCollapse file tree

2 files changed

+6
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+6
-0
lines changed
Open diff view settings
Collapse file

‎lib/_http_agent.js‎

Copy file name to clipboardExpand all lines: lib/_http_agent.js
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ function installListeners(agent, s, options) {
277277
s.removeListener('close', onClose);
278278
s.removeListener('free', onFree);
279279
s.removeListener('agentRemove', onRemove);
280+
s._httpMessage = null;
280281
}
281282
s.on('agentRemove', onRemove);
282283
}
Collapse file

‎test/parallel/test-http-connect.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-http-connect.js
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ server.listen(0, common.mustCall(() => {
4949
path: 'google.com:443'
5050
}, common.mustNotCall());
5151

52+
req.on('socket', common.mustCall((socket) => {
53+
assert.strictEqual(socket._httpMessage, req);
54+
}));
55+
5256
req.on('close', common.mustCall());
5357

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

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.