async function repeatUntilPassOrNull(asyncFn, maxAttempts = 3) {
  const errors = [];

  for (let i = 0; i < maxAttempts; i++) {
    try {
      return {result: await asyncFn(), retries: i, errors};
    } catch (err) {
      log.log('Error: ' + err.toString());
      errors.push(err.toString());
    }
  }

  return {result: null, retries: maxAttempts - 1, errors};
}
Repeats the ascyn function a maximum of maxAttempts times until it passes.
@param {() => Promise<Result>} asyncFn
@param {number} [maxAttempts]
@return {Promise<{result: Result|null, retries: number, errors: string[]}>}