Skip to content

Retry opening URL if worker-browser fails to send request within ackTimeout #123

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 31, 2015

Conversation

shirish87
Copy link
Contributor

  • Attempts to set the URL one additional time just in case a newly created (or reused) worker fails to set it
  • Similar in approach to the other PR on this issue
  • Incorporates changes requested and minor code cleanup

Run with --verbose to see ack check and re-request behaviour.

@@ -265,12 +252,14 @@ exports.Server = function Server(bsClient, workers) {
}

if (reusedWorker) {
logger.debug('[%s] Reused', getTestBrowserInfo(worker));
logger.debug('[%s] Reused', worker.getTestBrowserInfo());
worker.awaitAck(true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Boolean flags like this are difficult to understand without looking at the method signature. How about a separate resetAck() method that clears the timeout? Then you'd call both resetAck() and awaitAck() here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. I was contemplating adding a worker.reset() to reset state and timers for reused workers, but then thought of keeping the changes as local to this issue as possible. : )

@jzaefferer
Copy link
Contributor

Looks much better, still a few things to address.

@shirish87
Copy link
Contributor Author

Modified as per your suggestions. Let me know if you'd still like to use .bind instead of self refs : )

@jzaefferer
Copy link
Contributor

Looks good.

@jzaefferer
Copy link
Contributor

Should rebase/squash the whole thing into a single commit before landing it in master.

@shirish87
Copy link
Contributor Author

Done.

@jzaefferer
Copy link
Contributor

👍

shirish87 added a commit that referenced this pull request Jul 31, 2015
Retry opening URL if worker-browser fails to send request within ackTimeout
@shirish87 shirish87 merged commit 6afe714 into browserstack:master Jul 31, 2015
@nording
Copy link

nording commented Aug 13, 2015

After some digging I have found out that this pull request does not fix the blank page issue.
The reason for that is because of the following things:

    1. The worker acknowledge-state is not good enough to listen for, because it is not handle correct, sometimes you get "Received ack" before even the browser is launched. And when that happens and the page fails to load correct, the page won't reload again, because it check if the worker.isAckd is false before the reload. See ackTimeout function below:
 this.ackTimeout = setTimeout(function () {
      if (self.isAckd) { // Then if the page fails to load, this expression is getting true and then it return. And nothing else will happen
        // Already ack'd
        return;
      }

      // worker has not acknowledged itself in 60 sec, reopen url
      client.changeUrl(self.id, { url: self.buildUrl() }, function () {
        logger.debug("[%s] Sent Request to reload url", self.getTestBrowserInfo());
      });

    }, ackTimeout * 1000);

Example in the log:

[OS X Yosemite, Safari 8.0] Received ack
[OS X Yosemite, Safari 8.0] Launched
[OS X Yosemite, Safari 8.0] Awaiting ack

    1. When trying to reload the page, it does not include the worker_key data and therefore showing "404 Not found" when trying to reload.

Example:

00:01 - Open url http://localhost:8888/test.html?_worker_key=1539fd49-2783-4e91-8cfd-e192afec9f2c&_browser_string=OS%20X%20Yosemite%2C%20Safari%208.0
01:08 - Open url http://localhost:8888/test.html?_worker_key=&_browser_string=OS%20X%20Yosemite%2C%20Safari%208.0

    1. The function testActivityTimeout (in cli.js) will never execute anymore, because the property "acknowledged" on the worker object is never set to true. Instead another boolean is used to indicate if worker is acknowledge called isAckd. But that is not updated everywhere in the code.

I have done a temporary fix local, where I in the function "testActivityTimeout" try to reload the page 1 time if the test is not completed within the specified timeout.
It works and no more session timeout is visible.

Another solution I tried that worked was to listen if any request was made to "_/report" within the specified timeout, and if not reload the page, that also works.

Let me know if you have any questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants