@@ -85,7 +85,7 @@ export class CodeTime {
8585
8686 return new Promise ( ( resolve , reject ) => {
8787 const startTime = Date . now ( )
88- this . out . appendLine ( `[Req] ${ method } ${ path } proxy=${ proxy || 'none' } ` )
88+ this . out . appendLine ( `[Req] ${ method } ${ path } proxy=${ proxy ? this . redactUrlForLogging ( proxy ) : 'none' } ` )
8989
9090 const finish = ( parsed : { statusCode : number , body : string } ) => {
9191 this . out . appendLine ( `[Req] ${ parsed . statusCode } after ${ Date . now ( ) - startTime } ms` )
@@ -159,9 +159,15 @@ export class CodeTime {
159159 payload || '' ,
160160 ]
161161 socket . write ( lines . join ( '\r\n' ) )
162+
163+ const requestTimeout = setTimeout ( ( ) => {
164+ socket . destroy ( new Error ( 'request timeout' ) )
165+ } , 30_000 )
166+
162167 const chunks : Buffer [ ] = [ ]
163168 socket . on ( 'data' , ( chunk : Buffer ) => chunks . push ( chunk ) )
164169 socket . on ( 'end' , ( ) => {
170+ clearTimeout ( requestTimeout )
165171 socket . destroy ( )
166172 try {
167173 finish ( parseHttpResponse ( Buffer . concat ( chunks ) ) )
@@ -172,6 +178,7 @@ export class CodeTime {
172178 }
173179 } )
174180 socket . on ( 'error' , ( e : any ) => {
181+ clearTimeout ( requestTimeout )
175182 this . out . appendLine ( `[Req] socket error: ${ e . message } ` )
176183 reject ( e )
177184 } )
@@ -180,7 +187,6 @@ export class CodeTime {
180187 const onProxyReady = ( proxySocket : net . Socket | tls . TLSSocket ) => {
181188 if ( ! isHttpsTarget ) {
182189 this . out . appendLine ( `[Req] proxy connected, sending HTTP request (absolute form)` )
183- proxySocket . setTimeout ( 0 )
184190 writeRequestAndRead (
185191 proxySocket ,
186192 `${ method } ${ url . toString ( ) } HTTP/1.1` ,
@@ -217,7 +223,6 @@ export class CodeTime {
217223 reject ( new Error ( `Proxy CONNECT failed: ${ statusLine } ` ) )
218224 return
219225 }
220- proxySocket . setTimeout ( 0 )
221226 const residue = connectBuf . slice ( idx + 4 )
222227 if ( residue . length > 0 ) {
223228 proxySocket . unshift ( residue )
0 commit comments