File tree Expand file tree Collapse file tree 1 file changed +15
-6
lines changed Expand file tree Collapse file tree 1 file changed +15
-6
lines changed Original file line number Diff line number Diff line change @@ -14,16 +14,25 @@ async function checkStarted(selenium, seleniumStatusUrl) {
1414 selenium . stderr . on ( 'data' , ( d ) => ( cpState . stderr += d . toString ( ) ) ) ;
1515 }
1616
17- const options = {
17+ const DEFAULT_SELENUIM_CHECK_STARTED_TIMEOUT = 60000 ; // 1minute
18+ const DEFAULT_SELENUIM_CHECK_STARTED_PAUSE = 500 ; // 0.5 second
19+
20+ const serverStartupTimeoutMS =
21+ parseInt ( process . env . SELENUIM_CHECK_STARTED_TIMEOUT , 10 ) || DEFAULT_SELENUIM_CHECK_STARTED_TIMEOUT ;
22+
23+ const serverStartupPauseMs =
24+ parseInt ( process . env . SELENUIM_CHECK_STARTED_PAUSE , 10 ) || DEFAULT_SELENUIM_CHECK_STARTED_PAUSE ;
25+
26+ const gotOptions = {
1827 responseType : 'json' ,
19- timeout : 10000 ,
28+ timeout : serverStartupTimeoutMS ,
2029 retry : 0 ,
2130 } ;
2231
23- let attempts = 29 ;
32+ let attempts = serverStartupTimeoutMS / serverStartupPauseMs ;
2433 const startTime = Date . now ( ) ;
25- while ( attempts > 0 && Date . now ( ) - startTime < 30000 ) {
26- await sleep ( 500 ) ;
34+ while ( attempts > 0 && Date . now ( ) - startTime < serverStartupTimeoutMS ) {
35+ await sleep ( serverStartupPauseMs ) ;
2736 attempts -- ;
2837
2938 if ( cpState . exited ) {
@@ -34,7 +43,7 @@ async function checkStarted(selenium, seleniumStatusUrl) {
3443
3544 try {
3645 // server has one minute to start
37- await got ( seleniumStatusUrl , options ) ;
46+ await got ( seleniumStatusUrl , gotOptions ) ;
3847 selenium . removeListener ( 'exit' , errorIfNeverStarted ) ;
3948 return null ;
4049 } catch ( err ) {
You can’t perform that action at this time.
0 commit comments