You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// When connect() rejects, agent-base removes only its placeholder socket, so Node never drains this.requests[name] and requests queued past maxSockets hang forever.
208
+
// On a failure we dispatch the next queued request ourselves.
209
+
// See npm/cli#9386 and TooTallNate/proxy-agents#427.
210
+
createSocket(req,options,cb){
211
+
super.createSocket(req,options,(err,socket)=>{
212
+
if(err){
213
+
this.#drainPendingRequests(req,options)
214
+
}
215
+
cb(err,socket)
216
+
})
217
+
}
218
+
219
+
// Dispatch the next request queued behind maxSockets, reusing the slot the failed connection freed.
220
+
#drainPendingRequests (failedReq,options){
221
+
constname=this.getName(options)
222
+
constqueue=this.requests[name]
223
+
if(!queue||queue.length===0){
224
+
return
225
+
}
226
+
227
+
// Node's removeSocket() picks a queued request without shifting it off, so drop the failed one to avoid dispatching it twice.
228
+
constfailedIndex=queue.indexOf(failedReq)
229
+
if(failedIndex!==-1){
230
+
queue.splice(failedIndex,1)
231
+
}
232
+
if(queue.length===0){
233
+
deletethis.requests[name]
234
+
return
235
+
}
236
+
237
+
// Safety belt: only dispatch if a socket slot is genuinely free.
0 commit comments