Skip to content

Commit 447e6c4

Browse files
return error if tunnel failed to launch after 90 seconds
1 parent 4b9694e commit 447e6c4

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

lib/tunnel-launcher.js

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)