Skip to content

Commit e95b6e5

Browse files
committed
Merge pull request #33 from browserstack/timeout_fixes
Timeout fixes
2 parents 098bb4c + dcbade3 commit e95b6e5

File tree

2 files changed

+31
-21
lines changed

2 files changed

+31
-21
lines changed

bin/runner.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ function launchBrowser(browser, url) {
9494
} else {
9595
timeout = 300;
9696
}
97+
var activityTimeout = timeout - 10;
9798

9899
client.createWorker(browser, function (err, worker) {
99100
if (err || typeof worker !== 'object') {
@@ -125,18 +126,27 @@ function launchBrowser(browser, url) {
125126
if (!worker.acknowledged) {
126127
var subject = "Worker inactive for too long: " + worker.string;
127128
var content = "Worker details:\n" + JSON.stringify(worker.config, null, 4);
128-
129-
utils.alertBrowserStack(subject, content);
129+
client.takeScreenshot(worker.id, function(error, screenshot) {
130+
if (!error && screenshot.url) {
131+
console.log('[%s] Screenshot: %s', worker.string, screenshot.url);
132+
}
133+
utils.alertBrowserStack(subject, content);
134+
});
130135
}
131-
}, timeout * 1000);
136+
}, activityTimeout * 1000);
132137

133138
setTimeout(function () {
134139
if (workers[key]) {
135140
var subject = "Tests timed out on: " + worker.string;
136141
var content = "Worker details:\n" + JSON.stringify(worker.config, null, 4);
137-
utils.alertBrowserStack(subject, content);
142+
client.takeScreenshot(worker.id, function(error, screenshot) {
143+
if (!error && screenshot.url) {
144+
console.log('[%s] Screenshot: %s', worker.string, screenshot.url);
145+
}
146+
utils.alertBrowserStack(subject, content);
147+
});
138148
}
139-
}, (timeout * 1000));
149+
}, (activityTimeout * 1000));
140150
}
141151
});
142152
}, 2000);

lib/server.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -137,30 +137,30 @@ exports.Server = function Server(bsClient, workers) {
137137
if (worker) {
138138
bsClient.takeScreenshot(worker.id,function(error,screenshot){
139139
if(!error && screenshot.url){
140-
console.log('[%s] Screenshot: %s', worker.string, screenshot.url);
140+
console.log('[%s] Screenshot: %s', worker.string, screenshot.url);
141141
}
142142

143-
bsClient.terminateWorker(worker.id, function () {
144-
if (!workers[uuid]) {
145-
return;
146-
}
143+
bsClient.terminateWorker(worker.id, function () {
144+
if (!workers[uuid]) {
145+
return;
146+
}
147147

148-
console.log('[%s] Terminated', worker.string);
148+
console.log('[%s] Terminated', worker.string);
149149

150-
clearTimeout(workers[uuid].activityTimeout);
151-
delete workers[uuid];
150+
clearTimeout(workers[uuid].activityTimeout);
151+
delete workers[uuid];
152152

153-
if (utils.objectSize(workers) === 0) {
154-
console.log("All tests done, failures: %d.", status);
153+
if (utils.objectSize(workers) === 0) {
154+
console.log("All tests done, failures: %d.", status);
155155

156-
if (status > 0) {
157-
status = 1;
158-
}
156+
if (status > 0) {
157+
status = 1;
158+
}
159159

160-
process.exit(status);
161-
}
160+
process.exit(status);
161+
}
162+
});
162163
});
163-
});
164164
}
165165

166166
response.end();

0 commit comments

Comments
 (0)