From 8eda3c6512e4fcb4e681955250fbdff3d3cfcd55 Mon Sep 17 00:00:00 2001 From: Jonah Stiennon Date: Wed, 20 Jan 2016 11:33:45 -0800 Subject: [PATCH] pass sessionId arg when calling deleteSession. Make error message for NewCommandTimeout more helpful --- lib/commands/session.js | 2 +- lib/commands/timeout.js | 8 ++++++-- lib/driver.js | 6 +++--- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/commands/session.js b/lib/commands/session.js index ea9238d9f..ea061bd08 100644 --- a/lib/commands/session.js +++ b/lib/commands/session.js @@ -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; }; diff --git a/lib/commands/timeout.js b/lib/commands/timeout.js index baf8f10f4..56e492104 100644 --- a/lib/commands/timeout.js +++ b/lib/commands/timeout.js @@ -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 diff --git a/lib/driver.js b/lib/driver.js index 398515da8..9d4f62f7e 100644 --- a/lib/driver.js +++ b/lib/driver.js @@ -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 {