How to use the asyncbox.retry function in asyncbox

To help you get started, we’ve selected a few asyncbox examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github appium / appium-xcuitest-driver / lib / driver.js View on Github external
await retryInterval(startupRetries, startupRetryInterval, async () => {
        this.logEvent('wdaStartAttempted');
        if (retryCount > 0) {
          log.info(`Retrying WDA startup (${retryCount + 1} of ${startupRetries})`);
        }
        try {
          // on xcode 10 installd will often try to access the app from its staging
          // directory before fully moving it there, and fail. Retrying once
          // immediately helps
          const retries = this.xcodeVersion.major >= 10 ? 2 : 1;
          this.cachedWdaStatus = await retry(retries, this.wda.launch.bind(this.wda), sessionId, realDevice);
        } catch (err) {
          this.logEvent('wdaStartFailed');
          retryCount++;
          let errorMsg = `Unable to launch WebDriverAgent because of xcodebuild failure: ${err.message}`;
          if (this.isRealDevice()) {
            errorMsg += `. Make sure you follow the tutorial at ${WDA_REAL_DEV_TUTORIAL_URL}. ` +
                        `Try to remove the WebDriverAgentRunner application from the device if it is installed ` +
                        `and reboot the device.`;
          }
          await quitAndUninstall(errorMsg);
        }

        this.proxyReqRes = this.wda.proxyReqRes.bind(this.wda);
        this.jwpProxyActive = true;

        let originalStacktrace = null;
github appium / appium-uiautomator2-driver / test / functional / helpers / session.js View on Github external
} catch (ign) {}
  }

  if (CLOUD) {
    // on cloud tests, we want to set the `name` capability
    if (!caps.name) {
      caps.name = process.env.SAUCE_JOB_NAME || process.env.TRAVIS_JOB_NUMBER || 'unnamed';
    }
  }

  // Create a WD driver
  const host = getHost();
  const port = getPort();
  logger.debug(`Starting session on ${host}:${port}`);
  driver = await wd.promiseChainRemote(host, port);
  await retry(INIT_RETRIES, driver.init.bind(driver), caps);

  // In Travis, there is sometimes a popup
  if (CI && !CLOUD) {
    const startArgs = _.pick(caps, ['appPackage', 'appActivity', 'appWaitPackage', 'appWaitActivity', 'intentAction', 'intentCategory', 'intentFlags', 'optionalIntentArguments', 'dontStopAppOnReset', 'sessionId', 'id']);
    for (const btnId of ['android:id/button1', 'android:id/aerr_wait']) {
      let alertFound = false;
      await retryInterval(ALERT_CHECK_RETRIES, ALERT_CHECK_INTERVAL, async function () {
        let btn;
        try {
          btn = await driver.elementById(btnId);
          alertFound = true;
        } catch (ign) {
          // no element found, so just finish
          return;
        }
        logger.warn('*******************************************************');
github appium / appium-remote-debugger / test / functional / safari-e2e-specs.js View on Github external
before(async function () {
    sim = await getExistingSim(DEVICE_NAME, PLATFORM_VERSION);
    if (!sim) {
      const udid = await createDevice(SIM_NAME, DEVICE_NAME, PLATFORM_VERSION);
      sim = await getSimulator(udid);
      simCreated = true;
    }
    // on certain system, particularly Xcode 11 on Travis, starting the sim fails
    await retry(4, async function () {
      try {
        await sim.run({
          startupTimeout: 60000,
        });
      } catch (err) {
        await sim.shutdown();
        throw err;
      }
    });

    const port = await startHttpServer();
    address = `http://localhost:${port}`;
  });
  after(async function () {
github appium / appium-android-driver / lib / android-helpers.js View on Github external
helpers.installHelperApp = async function installHelperApp (adb, apkPath, packageId) {
  // Sometimes adb push or adb instal take more time than expected to install an app
  // e.g. https://github.com/appium/io.appium.settings/issues/40#issuecomment-476593174
  await retry(2, async function retryInstallHelperApp () {
    await adb.installOrUpgrade(apkPath, packageId, {grantPermissions: true});
  });
};
github appium / appium-xcuitest-driver / test / functional / web / helpers.js View on Github external
async function spinTitle (driver) {
  return await retry(10, async function () {
    const title = await driver.title();
    if (_.isNil(title)) {
      throw new Error('Did not get a page title');
    }
    return title;
  });
}
github appium / appium-adb / lib / tools / system-calls.js View on Github external
}
  if (!_.isEmpty(avdArgs)) {
    launchArgs.push(...(_.isArray(avdArgs) ? avdArgs : avdArgs.split(' ')));
  }
  log.debug(`Running '${emulatorBinaryPath}' with args: ${JSON.stringify(launchArgs)}`);
  let proc = new SubProcess(emulatorBinaryPath, launchArgs);
  await proc.start(0);
  proc.on('output', (stdout, stderr) => {
    for (let line of (stdout || stderr || '').split('\n').filter(Boolean)) {
      log.info(`[AVD OUTPUT] ${line}`);
    }
  });
  proc.on('die', (code, signal) => {
    log.warn(`Emulator avd ${avdName} exited with code ${code}${signal ? `, signal ${signal}` : ''}`);
  });
  await retry(retryTimes, async () => await this.getRunningAVDWithRetry(avdName, avdLaunchTimeout));
  await this.waitForEmulatorReady(avdReadyTimeout);
  return proc;
};
github appium / appium-xcode / lib / xcode.js View on Github external
function getInstrumentsPath (retries = DEFAULT_NUMBER_OF_RETRIES, timeout = XCRUN_TIMEOUT) {
    return retry(retries, getInstrumentsPathWithoutRetry, timeout);
  }
);
github Samsung / appium-sdb / lib / tools / system-calls.js View on Github external
}
      let args = this.executable.defaultArgs.concat(cmd);
      log.debug(`Running '${this.executable.path}' with args: ` +
        `${JSON.stringify(args)}`);
      let { stdout } = await exec(this.executable.path, args, opts);
      return stdout.trim();
    } catch (e) {
      if (e.stdout) {
        let stdout = e.stdout;
        return stdout;
      }
      throw new Error(`Error executing sdbExec. Original error: '${e.message}'; ` +
        `Stderr: '${(e.stderr || '').trim()}'; Code: '${e.code}'`);
    }
  };
  return await retry(2, execFunc);
};
github appium / appium-xcode / lib / xcode.js View on Github external
function getMaxTVOSSDK (retries = DEFAULT_NUMBER_OF_RETRIES, timeout = XCRUN_TIMEOUT) {
    return retry(retries, getMaxTVOSSDKWithoutRetry, timeout);
  }
);
github appium / appium-xcode / lib / xcode.js View on Github external
function getVersionMemoized (retries = DEFAULT_NUMBER_OF_RETRIES, timeout = XCRUN_TIMEOUT) {
    return retry(retries, getVersionWithoutRetry, timeout);
  }
);

asyncbox

A collection of small async/await utilities

Apache-2.0
Latest version published 1 year ago

Package Health Score

57 / 100
Full package analysis