Skip to content

Commit

Permalink
chore: Return better error on WDA startup timeout (#801)
Browse files Browse the repository at this point in the history
  • Loading branch information
mykola-mokhnach authored Oct 31, 2023
1 parent 2aa2a28 commit 796d5e7
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions lib/xcodebuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -405,12 +405,13 @@ class XcodeBuild {
this.log.debug(`Waiting up to ${this.launchTimeout}ms for WebDriverAgent to start`);
let currentStatus = null;
try {
let retries = parseInt(`${this.launchTimeout / 500}`, 10);
const retries = Math.trunc(this.launchTimeout / 500);
await retryInterval(retries, 1000, async () => {
if (this._didProcessExit) {
// there has been an error elsewhere and we need to short-circuit
return;
return currentStatus;
}

const proxyTimeout = this.noSessionProxy.timeout;
this.noSessionProxy.timeout = 1000;
try {
Expand All @@ -434,10 +435,11 @@ class XcodeBuild {

this.log.debug(`WebDriverAgent successfully started after ${timer.getDuration().asMilliSeconds.toFixed(0)}ms`);
} catch (err) {
// at this point, if we have not had any errors from xcode itself (reported
// elsewhere), we can let this go through and try to create the session
this.log.debug(err.message);
this.log.warn(`Getting status of WebDriverAgent on device timed out. Continuing`);
this.log.debug(err.stack);
throw new Error(
`We were not able to retrieve the /status response from the WebDriverAgent server after ${this.launchTimeout}ms timeout.` +
`Try to increase the value of 'appium:wdaLaunchTimeout' capability as a possible workaround.`
);
}
return currentStatus;
}
Expand Down

0 comments on commit 796d5e7

Please sign in to comment.