File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -689,14 +689,24 @@ ProxyAgent.prototype.createSocket = function(options, callback) {
689689 if ( res . statusCode === 200 ) {
690690 callback ( socket ) ;
691691 } else {
692- var err = new Error ( 'Proxy could not be established, code: ' + res . statusCode ) ;
692+ var err = new Error ( 'Proxy could not be established (maybe a problem in auth) , code: ' + res . statusCode ) ;
693693 err . code = 'ECONNRESET' ;
694694 options . request . emit ( 'error' , err ) ;
695+ req . destroy && req . destroy ( ) ;
696+ req = null ;
697+ self . requests = null ;
698+ self . options = null ;
695699 }
696700 } ) ;
697701
698702 req . on ( 'error' , function ( err ) {
699- options . request . emit ( 'error' , err ) ;
703+ var e = new Error ( 'Request Proxy "proxy {0} --> target {1}": {2}' . format ( PROXYOPTIONS . host + ':' + proxy . port , PROXYOPTIONS . path , err . toString ( ) ) ) ;
704+ e . code = err . code ;
705+ options . request . emit ( 'error' , e ) ;
706+ req . destroy && req . destroy ( ) ;
707+ req = null ;
708+ self . requests = null ;
709+ self . options = null ;
700710 } ) ;
701711
702712 req . end ( ) ;
You can’t perform that action at this time.
0 commit comments