async reset () {
    log.debug('Resetting app mid-session');
    log.debug('Running generic full reset');

    // preserving state
    let currentConfig = {};
    for (let property of ['implicitWaitMs', 'newCommandTimeoutMs', 'sessionId', 'resetOnUnexpectedShutdown']) {
      currentConfig[property] = this[property];
    }

    // We also need to preserve the unexpected shutdown, and make sure it is not cancelled during reset.
    this.resetOnUnexpectedShutdown = () => {};

    try {
      await this.deleteSession(this.sessionId);
      log.debug('Restarting app');
      await this.createSession(this.caps);
    } finally {
      // always restore state.
      for (let [key, value] of _.toPairs(currentConfig)) {
        this[key] = value;
      }
    }
    this.clearNewCommandTimeout();
  }
/*
   * Restart the session with the original caps,
   * preserving the timeout config.
   */
Restart the session with the original caps,
preserving the timeout config.
Restart the session with the original caps preserving the timeout config .
async reset () {
    log.debug('Resetting app mid-session');
    log.debug('Running generic full reset');
    let currentConfig = {};
    for (let property of ['implicitWaitMs', 'newCommandTimeoutMs', 'sessionId', 'resetOnUnexpectedShutdown']) {
      currentConfig[property] = this[property];
    }
    this.resetOnUnexpectedShutdown = () => {};
    try {
      await this.deleteSession(this.sessionId);
      log.debug('Restarting app');
      await this.createSession(this.caps);
    } finally {
      for (let [key, value] of _.toPairs(currentConfig)) {
        this[key] = value;
      }
    }
    this.clearNewCommandTimeout();
  }
async reset ( ) { log . debug ( 'Resetting app mid-session' ) ; log . debug ( 'Running generic full reset' ) ; let currentConfig = { } ; for ( let property of [ 'implicitWaitMs' , 'newCommandTimeoutMs' , 'sessionId' , 'resetOnUnexpectedShutdown' ] ) { currentConfig [ property ] = this [ property ] ; } this . resetOnUnexpectedShutdown = ( ) => { } ; try { await this . deleteSession ( this . sessionId ) ; log . debug ( 'Restarting app' ) ; await this . createSession ( this . caps ) ; } finally { for ( let [ key , value ] of _ . toPairs ( currentConfig ) ) { this [ key ] = value ; } } this . clearNewCommandTimeout ( ) ; }
Restart the session with the original caps,
 preserving the timeout config.
Restart the session with the original caps preserving the timeout config .
// preserving state // We also need to preserve the unexpected shutdown, and make sure it is not cancelled during reset. // always restore state.