GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — http: free listeners on free sockets · nodejs/node@b840eb7

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib
    • _http_client.js
  • test/parallel
    • test-http-agent-keepalive.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/_http_client.js‎

Copy file name to clipboardExpand all lines: lib/_http_client.js
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,8 @@ function responseKeepAlive(req) {
612612
}
613613
socket.removeListener('close', socketCloseListener);
614614
socket.removeListener('error', socketErrorListener);
615+
socket.removeListener('data', socketOnData);
616+
socket.removeListener('end', socketOnEnd);
615617
socket.once('error', freeSocketErrorListener);
616618
// There are cases where _handle === null. Avoid those. Passing null to
617619
// nextTick() will call getDefaultTriggerAsyncId() to retrieve the id.
Collapse file

‎test/parallel/test-http-agent-keepalive.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-http-agent-keepalive.js
+15-3Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,21 @@ server.listen(0, common.mustCall(() => {
140140

141141
// Check for listener leaks when reusing sockets.
142142
function checkListeners(socket) {
143-
assert.strictEqual(socket.listenerCount('data'), 1);
144-
assert.strictEqual(socket.listenerCount('drain'), 1);
143+
const callback = common.mustCall(() => {
144+
if (!socket.destroyed) {
145+
assert.strictEqual(socket.listenerCount('data'), 0);
146+
assert.strictEqual(socket.listenerCount('drain'), 0);
147+
// Sockets have freeSocketErrorListener.
148+
assert.strictEqual(socket.listenerCount('error'), 1);
149+
// Sockets have onReadableStreamEnd.
150+
assert.strictEqual(socket.listenerCount('end'), 1);
151+
}
152+
153+
socket.off('free', callback);
154+
socket.off('close', callback);
155+
});
145156
assert.strictEqual(socket.listenerCount('error'), 1);
146-
// Sockets have onReadableStreamEnd.
147157
assert.strictEqual(socket.listenerCount('end'), 2);
158+
socket.once('free', callback);
159+
socket.once('close', callback);
148160
}

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.