code: async function retryPromise(fn, attempts, backoff) {
      let aborted = false;
  
      try {
          const data = await fn(() => { aborted = true; });
          return data;
      }
      catch (e) {
          if (aborted || ((backoff.attempts + 1) >= attempts)) {
              throw e;
          }
  
          const duration = backoff.duration();
          debug(`Promise rejected attempt #${backoff.attempts}, retrying in ${duration}ms: ${e.message}`);
  
          await Promise.delay(duration);
          return retryPromise(fn, attempts, backoff);
      }
  }
docs: Retry promise
  
  @param {function} fn Function returning promise that should be retried
  @param {number} attempts Maximum number of attempts
  @param {Backoff} backoff Backoff instance
  @returns {Promise}