MCPcopy
hub / github.com/nodejs/undici / closeClientIfUnused

Method closeClientIfUnused

lib/dispatcher/agent.js:95–120  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

93 : this[kOptions])
94
95 const closeClientIfUnused = () => {
96 if (this[kClients].get(key) !== dispatcher) {
97 return
98 }
99
100 if (dispatcher[kConnected] > 0 || dispatcher[kBusy]) {
101 return
102 }
103
104 this[kClients].delete(key)
105 if (!dispatcher.destroyed) {
106 dispatcher.close()
107 }
108
109 let hasOrigin = false
110 for (const client of this[kClients].values()) {
111 if (client[kUrl].origin === dispatcher[kUrl].origin) {
112 hasOrigin = true
113 break
114 }
115 }
116
117 if (!hasOrigin) {
118 this[kOrigins].delete(dispatcher[kUrl].origin)
119 }
120 }
121
122 dispatcher
123 .on('drain', this[kOnDrain])

Callers

nothing calls this directly

Calls 4

valuesMethod · 0.80
getMethod · 0.65
deleteMethod · 0.65
closeMethod · 0.65

Tested by

no test coverage detected