@@ -415,6 +415,7 @@ async function runCPUBenchmark(framework: FrameworkData, benchmark: Benchmark, b
415
415
await afterBenchmark ( driver , benchmark , framework ) ;
416
416
await driver . executeScript ( "console.timeStamp('afterBenchmark')" ) ;
417
417
} catch ( e ) {
418
+ console . log ( e ) ;
418
419
errors . push ( await registerError ( driver , framework , benchmark , e , ) ) ;
419
420
throw e ;
420
421
}
@@ -473,6 +474,7 @@ async function runMemBenchmark(framework: FrameworkData, benchmark: Benchmark, b
473
474
allResults . push ( result ) ;
474
475
} catch ( e ) {
475
476
errors . push ( await registerError ( driver , framework , benchmark , e , ) ) ;
477
+ console . log ( e ) ;
476
478
throw e ;
477
479
} finally {
478
480
await driver . close ( ) ;
@@ -494,6 +496,7 @@ async function runStartupBenchmark(framework: FrameworkData, benchmark: Benchmar
494
496
try {
495
497
results . push ( await runLighthouse ( framework , benchmarkOptions ) ) ;
496
498
} catch ( error ) {
499
+ console . log ( error ) ;
497
500
errors . push ( { imageFile : null , exception : error } ) ;
498
501
throw error ;
499
502
}
@@ -523,24 +526,36 @@ export async function executeBenchmark(frameworks: FrameworkData[], keyed: boole
523
526
return errorsAndWarnings ;
524
527
}
525
528
529
+ export async function benchmarkWithRetry ( frameworks : FrameworkData [ ] , keyed : boolean , frameworkName : string , benchmarkName : string , benchmarkOptions : BenchmarkOptions , retryCount : number ) : Promise < ErrorsAndWarning > {
530
+ try {
531
+ let errorsAndWarnings = await executeBenchmark ( frameworks , keyed , frameworkName , benchmarkName , benchmarkOptions ) ;
532
+ if ( config . LOG_DEBUG ) console . log ( "benchmark finished - got errors promise" , errorsAndWarnings ) ;
533
+ process . send ( errorsAndWarnings ) ;
534
+ process . exit ( 0 ) ;
535
+ return errorsAndWarnings ;
536
+ } catch ( err ) {
537
+ console . log ( "error running benchmark" , err ) ;
538
+ if ( retryCount > 1 ) {
539
+ console . log ( "************* RETRY BENCHMARK *******************" , retryCount ) ;
540
+ benchmarkWithRetry ( frameworks , keyed , frameworkName , benchmarkName , benchmarkOptions , retryCount - 1 ) ;
541
+ } else {
542
+ console . log ( "max retry reached" ) ;
543
+ process . exit ( 1 ) ;
544
+ }
545
+ }
546
+ }
547
+
526
548
process . on ( 'message' , ( msg ) => {
527
549
if ( config . LOG_DEBUG ) console . log ( "child process got message" , msg ) ;
528
550
529
551
let { frameworks, keyed, frameworkName, benchmarkName, benchmarkOptions} : { frameworks : FrameworkData [ ] , keyed : boolean , frameworkName : string , benchmarkName : string , benchmarkOptions : BenchmarkOptions } = msg ;
530
552
if ( ! benchmarkOptions . port ) benchmarkOptions . port = config . PORT . toFixed ( ) ;
531
-
532
- try {
533
- let errorsPromise = executeBenchmark ( frameworks , keyed , frameworkName , benchmarkName , benchmarkOptions ) ;
534
- errorsPromise . then ( errorsAndWarnings => {
535
- if ( config . LOG_DEBUG ) console . log ( "benchmark finished - got errors promise" , errorsAndWarnings ) ;
536
- process . send ( errorsAndWarnings ) ;
537
- process . exit ( 0 ) ;
538
- } ) . catch ( err => {
539
- console . log ( "error running benchmark" , err ) ;
540
- process . exit ( 1 ) ;
541
- } ) ;
542
- } catch ( err ) {
543
- console . log ( "error running benchmark" , err ) ;
544
- process . exit ( 1 ) ;
553
+ const MAX_RETRY = 3 ;
554
+ try {
555
+ benchmarkWithRetry ( frameworks , keyed , frameworkName , benchmarkName , benchmarkOptions , MAX_RETRY )
556
+ } catch ( err ) {
557
+ console . log ( "direct error" , err ) ;
558
+ process . exit ( 1 ) ;
559
+ }
545
560
}
546
- } ) ;
561
+ ) ;
0 commit comments