File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed
packages/extester/src/util Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ import { promisify } from 'util';
2020import stream from 'stream' ;
2121import { HttpProxyAgent , HttpsProxyAgent } from 'hpagent' ;
2222
23+ const retryCount = 3 ;
2324const httpProxyAgent = ! process . env . HTTP_PROXY
2425 ? undefined
2526 : new HttpProxyAgent ( {
@@ -40,6 +41,9 @@ const options = {
4041 http : httpProxyAgent ,
4142 https : httpsProxyAgent ,
4243 } ,
44+ retry : {
45+ limit : retryCount ,
46+ } ,
4347} ;
4448
4549export class Download {
@@ -53,6 +57,10 @@ export class Download {
5357 let lastTick = 0 ;
5458 const got = ( await import ( 'got' ) ) . default ;
5559 const dlStream = got . stream ( uri , options ) ;
60+ // needed in order to enable retry feature:
61+ dlStream . once ( 'retry' , ( newRetryCount : number , error ) => {
62+ console . warn ( `retry(${ newRetryCount } ): Failed getting ${ uri } due to ${ error } ` ) ;
63+ } ) ;
5664 if ( progress ) {
5765 dlStream . on ( 'downloadProgress' , ( { transferred, total, percent } ) => {
5866 const currentTime = Date . now ( ) ;
You can’t perform that action at this time.
0 commit comments