File tree Expand file tree Collapse file tree 1 file changed +21
-5
lines changed Expand file tree Collapse file tree 1 file changed +21
-5
lines changed Original file line number Diff line number Diff line change @@ -105,16 +105,32 @@ function run (options, callback) {
105105 logger ( 'Tunnel is ready' )
106106 callback ( null , activeTunnel )
107107 }
108-
108+
109+ const onError = function ( waitCounter ) {
110+ const errorMessage = `Tunnel failed to launch in ${ waitCounter } seconds.`
111+ logger ( errorMessage )
112+ callback ( new Error ( errorMessage ) , null )
113+ }
114+
109115 const readyFile = path . join ( os . tmpdir ( ) , 'testingbot.ready' )
110- const readyFileChecker = setInterval ( ( ) => {
111- fs . stat ( readyFile , ( error , stat ) => {
116+
117+ function checkReadyFile ( waitCounter = 0 ) {
118+ fs . access ( readyFile , fs . constants . F_OK , ( error ) => {
112119 if ( ! error ) {
113120 clearInterval ( readyFileChecker )
114- onReady ( )
121+ return onReady ( )
115122 }
123+
124+ if ( waitCounter > 90 ) {
125+ clearInterval ( readyFileChecker )
126+ return onError ( waitCounter )
127+ }
128+
129+ waitCounter += 1
116130 } )
117- } , 800 )
131+ }
132+
133+ const readyFileChecker = setInterval ( ( ) => checkReadyFile ( ) , 1000 )
118134
119135 const args = createArgs ( options )
120136
You can’t perform that action at this time.
0 commit comments