mirror of
https://github.com/appium/appium.git
synced 2026-10-29 12:41:58 +08:00
better command timeouts
This commit is contained in:
+13
-2
@@ -22,10 +22,21 @@ helpers.clearNewCommandTimeout = function () {
|
||||
}
|
||||
};
|
||||
|
||||
helpers.startNewCommandTimeout = function (onCommandTimeout) {
|
||||
helpers.startNewCommandTimeout = function (cmd) {
|
||||
// make sure there are no rogue timeouts
|
||||
this.clearNewCommandTimeout();
|
||||
|
||||
// if command timeout is 0, it is disabled
|
||||
if(!this.newCommandTimeoutMs) return;
|
||||
|
||||
// TODO: replace setTimeout by CancellableDelay
|
||||
this.noCommandTimer = setTimeout(() => {
|
||||
B.resolve(onCommandTimeout()).done();
|
||||
let onCommand = async () => {
|
||||
log.warn(`Shutting down because we waited ` +
|
||||
`${this.newCommandTimeoutMs / 1000} seconds for a command`);
|
||||
await this.startUnexpectedShutdown(new Error(`Command ${cmd} timed out!`));
|
||||
};
|
||||
B.resolve(onCommand()).done();
|
||||
}, this.newCommandTimeoutMs);
|
||||
};
|
||||
|
||||
|
||||
+2
-7
@@ -163,14 +163,9 @@ class BaseDriver extends MobileJsonWireProtocol {
|
||||
// automatic session deletion in this.onCommandTimeout. Of course we don't
|
||||
// want to trigger the timer when the user is shutting down the session
|
||||
// intentionally
|
||||
if (this.newCommandTimeoutMs && cmd !== 'deleteSession') {
|
||||
if (cmd !== 'deleteSession') {
|
||||
// reseting existing timeout
|
||||
this.clearNewCommandTimeout();
|
||||
this.startNewCommandTimeout(async () => {
|
||||
log.warn(`Shutting down because we waited ` +
|
||||
`${this.newCommandTimeoutMs / 1000} seconds for a command`);
|
||||
await this.startUnexpectedShutdown(new Error(`Command ${cmd} timed out!`));
|
||||
});
|
||||
this.startNewCommandTimeout(cmd);
|
||||
}
|
||||
|
||||
return res;
|
||||
|
||||
Reference in New Issue
Block a user