Skip to content

Commit

Permalink
[Misc] Add debug information to better understand the timeout cause
Browse files Browse the repository at this point in the history
  • Loading branch information
vmassol committed Aug 24, 2022
1 parent 772dd8b commit 7f27e56
Showing 1 changed file with 9 additions and 3 deletions.
Expand Up @@ -143,13 +143,15 @@ private void waitForChromeService(int timeoutSeconds) throws TimeoutException

int timeoutMillis = timeoutSeconds * 1000;
long start = System.currentTimeMillis();
Exception exception = null;

while (System.currentTimeMillis() - start < timeoutMillis) {
try {
this.chromeService.getVersion();
return;
} catch (Exception e) {
this.logger.debug("Chrome remote debugging not available. Retrying in 2s.");
exception = e;
this.logger.debug("Chrome remote debugging not available. Retrying in 2s.", e);
try {
Thread.sleep(2000);
} catch (InterruptedException ie) {
Expand All @@ -162,8 +164,12 @@ private void waitForChromeService(int timeoutSeconds) throws TimeoutException
}

long waitTime = (System.currentTimeMillis() - start) / 1000;
throw new TimeoutException(String
.format("Timeout waiting for Chrome remote debugging to become available. Waited [%s] seconds.", waitTime));
String message = String.format("Timeout waiting for Chrome remote debugging to become available. Waited [%s] "
+ "seconds", waitTime);
if (exception != null) {
message = String.format("%s. Root cause: [%s]", ExceptionUtils.getRootCauseMessage(exception));
}
throw new TimeoutException(message);
}

/**
Expand Down

0 comments on commit 7f27e56

Please sign in to comment.