Permalink
Browse files

Attempt to page.open again if first attempt fails.

  • Loading branch information...
1 parent a15bbed commit 49beabad93194de9e799eac7d511c87b161a2ddb @reid reid committed Aug 26, 2012
Showing with 24 additions and 6 deletions.
  1. +24 −6 test/functional.js
View
@@ -59,12 +59,15 @@ function captureContext(batchContext) {
browser.createPage(function (page) {
var timeout = setTimeout(function () {
vow.callback(new Error("The capture page took too long to load."));
- }, 5000);
+ }, 10000),
+ openAttempts = 0,
+ loaded = false;
lastTopic.client.once("agentConnect", function (agent) {
lastTopic.client.once("agentSeen", function () {
page.evaluate(getPathname, function (url) {
clearTimeout(timeout);
+ loaded = true;
vow.callback(null, {
url: url,
page: page,
@@ -90,11 +93,26 @@ function captureContext(batchContext) {
});
}
- page.open(lastTopic.url, function (status) {
- if (status !== "success") {
- vow.callback(new Error("Failed to load page."));
- }
- });
+ (function opener() {
+ page.open(lastTopic.url, function (status) {
+ if (status !== "success") {
+ openAttempts += 1;
+ if (openAttempts > 5) {
+ vow.callback(new Error("Failed to load page, URL: " + lastTopic.url +
+ ", status: " + status));
+ return;
+ }
+ if (!loaded) {
+ if (process.env.TRAVIS) {
+ console.log("Failed to open load page, URL: " + lastTopic.url +
+ ", attempt " + openAttempts +
+ ", scheduling next attempt in 500ms.");
+ }
+ setTimeout(opener, 500);
+ }
+ }
+ });
+ }());
});
},
"did not throw": didNotThrow,

0 comments on commit 49beaba

Please sign in to comment.