INNER CODE UNIT · TypeScript

gotoWithRetry

mifi/instauto · src/index.ts:382

  async function gotoWithRetry(url: string) {
    const maxAttempts = 3;
    for (let attempt = 0; ; attempt += 1) {
      logger.log(`Goto ${url}`);
      const response = await gotoUrl(url);
      if (!response) throw new Error('Navigation did not return a response');
      const status = response.status();
      logger.log('Page loaded');
      await sleep(2000);

      // https://www.reddit.com/r/Instagram/comments/kwrt0s/error_560/
      // https://github.com/mifi/instauto/issues/60
      if (![560, 429].includes(status)) return status;

      if (attempt > maxAttempts) {
        throw new Error(`Navigate to user failed after ${maxAttempts} attempts, last status: ${status}`);
      }

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…