bare-http1 4.2.2 → 4.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/agent.js +5 -1
  2. package/package.json +1 -1
package/lib/agent.js CHANGED
@@ -60,6 +60,8 @@ module.exports = class HTTPAgent extends EventEmitter {
60
60
  socket.on('free', onfree).on('end', onremove).on('finish', onremove).on('timeout', ontimeout)
61
61
 
62
62
  function onfree() {
63
+ if (socket.destroyed) return
64
+
63
65
  if (agent.keepSocketAlive(socket)) {
64
66
  onremove(false)
65
67
 
@@ -75,6 +77,8 @@ module.exports = class HTTPAgent extends EventEmitter {
75
77
  }
76
78
 
77
79
  function onremove(destroy = true) {
80
+ if (destroy) socket.off('free', onfree)
81
+
78
82
  for (const set of destroy ? [agent._sockets, agent._freeSockets] : [agent._sockets]) {
79
83
  const sockets = set.get(name)
80
84
  if (sockets === undefined) continue
@@ -89,7 +93,7 @@ module.exports = class HTTPAgent extends EventEmitter {
89
93
  }
90
94
  }
91
95
 
92
- function ontimeout(socket, name) {
96
+ function ontimeout() {
93
97
  const sockets = agent._freeSockets.get(name)
94
98
  if (sockets === undefined) return
95
99
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bare-http1",
3
- "version": "4.2.2",
3
+ "version": "4.2.4",
4
4
  "description": "Native HTTP/1 library for JavaScript",
5
5
  "exports": {
6
6
  "./package": "./package.json",