File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -198,6 +198,11 @@ function requestAsEventEmitter(opts) {
198198 const uploadEventFrequency = 150 ;
199199
200200 progressInterval = setInterval ( ( ) => {
201+ if ( socket . destroyed ) {
202+ clearInterval ( progressInterval ) ;
203+ return ;
204+ }
205+
201206 const lastUploaded = uploaded ;
202207 const headersSize = Buffer . byteLength ( req . _header ) ;
203208 uploaded = socket . bytesWritten - headersSize ;
Original file line number Diff line number Diff line change 1+ import test from 'ava' ;
2+ import got from '..' ;
3+
4+ test . serial ( 'clear the progressInterval if the socket has been destroyed' , async t => {
5+ const handlesComingFromAVA = 2 ;
6+ const err = await t . throws ( got ( `http://127.0.0.1:55555` , { retry : 0 } ) ) ;
7+ t . is ( process . _getActiveHandles ( ) . length - handlesComingFromAVA , 2 ) ;
8+ t . is ( err . code , 'ECONNREFUSED' ) ;
9+ } ) ;
You can’t perform that action at this time.
0 commit comments