Skip to content

Commit 204e721

Browse files
author
Rohan Jain
committed
Alerts when tunnel/worker takes too long to respond
1 parent b332a59 commit 204e721

File tree

3 files changed

+28
-4
lines changed

3 files changed

+28
-4
lines changed

bin/runner.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,22 @@ function launchBrowser(browser) {
8383
runningChecked = true;
8484
clearInterval(statusPoller);
8585
console.log('[%s] Launched', worker.string);
86+
87+
setTimeout(function () {
88+
if (!worker.acknowledged) {
89+
utils.alertBrowserStack('Worker inactive for too long',
90+
JSON.stringify(worker), function () {
91+
process.exit(-2);
92+
})
93+
}
94+
}, 120 * 1000);
8695
}
8796
});
8897
}, 2000);
8998
});
9099
}
91100

92-
if (config.browsers) {
101+
if (config.browsers && config.browsers.length > 0) {
93102
tunnel = new Tunnel(config.key, serverPort, function () {
94103
config.browsers.forEach(function(browser) {
95104
if (browser.browser_version === "latest") {

lib/server.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ exports.Server = function Server(bsClient, workers) {
2121
var status = 0;
2222

2323
function handleFile (filename, request, response) {
24+
var url_parts = url.parse(request.url, true);
25+
var query = url_parts.query;
26+
27+
if (query._worker_key) {
28+
workers[query._worker_key].acknowledged = true;
29+
}
30+
2431
fs.exists(filename, function(exists) {
2532
if(!exists) {
2633
response.writeHead(404, {"Content-Type": "text/plain"});

lib/tunnel.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
var exec = require('child_process').exec,
22
fs = require('fs'),
33
http = require('http'),
4-
tunnelJar = '/tmp/BrowserStackTunnel.jar';
4+
tunnelJar = '/tmp/BrowserStackTunnel.jar',
5+
utils = require('./utils');
56

67
var Tunnel = function Tunnel (key, port, callback, err) {
78
var that = {};
@@ -29,6 +30,15 @@ var Tunnel = function Tunnel (key, port, callback, err) {
2930
var running = false;
3031
var runMatcher = "You can now access your local server(s)";
3132

33+
setTimeout(function () {
34+
if (!running) {
35+
utils.alertBrowserStack('Tunnel launch timeout',
36+
'Stdout:\n' + data, function () {
37+
process.exit(-2);
38+
});
39+
}
40+
}, 60 * 100);
41+
3242
subProcess.stdout.on('data', function (_data) {
3343
if (running) {
3444
return;
@@ -41,8 +51,6 @@ var Tunnel = function Tunnel (key, port, callback, err) {
4151
console.log("..Done");
4252
callback();
4353
}
44-
45-
running = true;
4654
});
4755

4856
that.process = subProcess;

0 commit comments

Comments
 (0)