pass sessionId arg when calling deleteSession. Make error message for NewCommandTimeout more helpful

This commit is contained in:
Jonah Stiennon
2016-01-20 13:40:43 -08:00
parent b49464b59f
commit 8eda3c6512
3 changed files with 10 additions and 6 deletions
+1 -1
View File
@@ -54,7 +54,7 @@ commands.getSession = async function () {
return this.caps;
};
commands.deleteSession = async function () {
commands.deleteSession = async function (/* sessionId */) {
this.clearNewCommandTimeout();
this.sessionId = null;
};
+6 -2
View File
@@ -24,7 +24,7 @@ helpers.clearNewCommandTimeout = function () {
}
};
helpers.startNewCommandTimeout = function (cmd) {
helpers.startNewCommandTimeout = function () {
// make sure there are no rogue timeouts
this.clearNewCommandTimeout();
@@ -36,7 +36,11 @@ helpers.startNewCommandTimeout = function (cmd) {
.then(async () => {
log.warn(`Shutting down because we waited ` +
`${this.newCommandTimeoutMs / 1000} seconds for a command`);
await this.startUnexpectedShutdown(new Error(`Command ${cmd} timed out!`));
let errorMessage = `New Command Timeout of ` +
`${this.newCommandTimeoutMs / 1000} seconds ` +
`expired. Try customizing the timeout using the ` +
`'newCommandTimeout' desired capability`;
await this.startUnexpectedShutdown(new Error(errorMessage));
})
.catch(B.CancellationError, (/*err*/) => {
// ignore
+3 -3
View File
@@ -175,7 +175,7 @@ class BaseDriver extends MobileJsonWireProtocol {
// intentionally
if (cmd !== 'deleteSession') {
// reseting existing timeout
this.startNewCommandTimeout(cmd);
this.startNewCommandTimeout();
}
return res;
@@ -185,7 +185,7 @@ class BaseDriver extends MobileJsonWireProtocol {
this.unexpectedShutdownDeferred.reject(err); // allow others to listen for this
this.curCommandCancellable.cancel(err);
this.shutdownUnexpectedly = true;
await this.deleteSession();
await this.deleteSession(this.sessionId);
this.shutdownUnexpectedly = false;
}
@@ -219,7 +219,7 @@ class BaseDriver extends MobileJsonWireProtocol {
this.resetOnUnexpectedShutdown = () => {};
try {
await this.deleteSession();
await this.deleteSession(this.sessionId);
log.debug('Restarting app');
await this.createSession(this.caps);
} finally {