fetch-filecache.js
async function fetchWithRetry(url, options, remainingAttempts) {
      try {
        return await baseFetch(url, options);
      }
      catch (err) {
        if (remainingAttempts <= 0) throw err;
        log('fetch attempt failed, sleep and try again');
        await sleep(2000 + Math.floor(Math.random() * 8000));
        return fetchWithRetry(url, options, remainingAttempts - 1);
      }
    }
async function fetchWithRetry(url, options, remainingAttempts) {
      try {
        return await baseFetch(url, options);
      }
      catch (err) {
        if (remainingAttempts <= 0) throw err;
        log('fetch attempt failed, sleep and try again');
        await sleep(2000 + Math.floor(Math.random() * 8000));
        return fetchWithRetry(url, options, remainingAttempts - 1);
      }
    }
async function fetchWithRetry ( url , options , remainingAttempts ) { try { return await baseFetch ( url , options ) ; } catch ( err ) { if ( remainingAttempts <= 0 ) throw err ; log ( 'fetch attempt failed, sleep and try again' ) ; await sleep ( 2000 + Math . floor ( Math . random ( ) * 8000 ) ) ; return fetchWithRetry ( url , options , remainingAttempts - 1 ) ; } }
To overcome transient network errors, we'll fetch the same URL again a few times before we surrender when a network error occurs, letting a few seconds elapse between attempts
To overcome transient network errors we ll fetch the same URL again a few times before we surrender when a network error occurs letting a few seconds elapse between attempts