@@ -201,8 +201,9 @@ function maybeEnableKeylog(eventName) {
201201 agent . emit ( 'keylog' , keylog , this ) ;
202202 } ;
203203 // Existing sockets will start listening on keylog now.
204- for ( const socket of ObjectValues ( this . sockets ) ) {
205- socket . on ( 'keylog' , this [ kOnKeylog ] ) ;
204+ const sockets = ObjectValues ( this . sockets ) ;
205+ for ( let i = 0 ; i < sockets . length ; i ++ ) {
206+ sockets [ i ] . on ( 'keylog' , this [ kOnKeylog ] ) ;
206207 }
207208 }
208209}
@@ -426,7 +427,9 @@ Agent.prototype.removeSocket = function removeSocket(s, options) {
426427 if ( ! s . writable )
427428 ArrayPrototypePush ( sets , this . freeSockets ) ;
428429
429- for ( const sockets of sets ) {
430+ for ( let sk = 0 ; sk < sets . length ; sk ++ ) {
431+ const sockets = sets [ sk ] ;
432+
430433 if ( sockets [ name ] ) {
431434 const index = ArrayPrototypeIndexOf ( sockets [ name ] , s ) ;
432435 if ( index !== - 1 ) {
@@ -492,10 +495,14 @@ Agent.prototype.reuseSocket = function reuseSocket(socket, req) {
492495} ;
493496
494497Agent . prototype . destroy = function destroy ( ) {
495- for ( const set of [ this . freeSockets , this . sockets ] ) {
496- for ( const key of ObjectKeys ( set ) ) {
497- for ( const setName of set [ key ] ) {
498- setName . destroy ( ) ;
498+ const sets = [ this . freeSockets , this . sockets ] ;
499+ for ( let s = 0 ; s < sets . length ; s ++ ) {
500+ const set = sets [ s ] ;
501+ const keys = ObjectKeys ( set ) ;
502+ for ( let v = 0 ; v < keys . length ; v ++ ) {
503+ const setName = set [ keys [ v ] ] ;
504+ for ( let n = 0 ; n < setName . length ; n ++ ) {
505+ setName [ n ] . destroy ( ) ;
499506 }
500507 }
501508 }
0 commit comments