title: Handling network errors with Puppeteer
body: <p>Has anyone ever tried to handle network connexion errors with Puppeteer ? I tried by launching a random page and checking if I receive no errors until it works ( this try is in a for loop ) :</p>
  
  <pre><code>try{
          responseAwait = await page1.goto('https://www.residentadvisor.net/dj.aspx?country=01')
          } catch (err) {
          console.log('Page load fail : '+ err)
          if (err == 'Error: net::ERR_INTERNET_DISCONNECTED' || err == 'Error: net::ERR_NETWORK_CHANGED' || err == 'Error: net::ERR_NAME_NOT_RESOLVED'){
          let refreshIntervalId = setInterval(() =&gt;{
             handleConnexionError(refreshIntervalId,page1)
          }, 5000) 
      }
      }
  </code></pre>
  
  <p>And here is the function that I use in order to check if the network is back :</p>
  
  <pre><code>async function handleConnexionError(refreshIntervalId,page1){
      console.log('Retrying to connect')
      let errorHandle = true
      await page1.goto('https://www.residentadvisor.net/dj.aspx?country=01').catch(() =&gt; {
          errorHandle = false
      })
      if (errorHandle) {
          console.log('Succesfully Reconnected')
          clearInterval(refreshIntervalId)
          return true
      }
      else {
          console.log('Connection Fail Retrying in 10 sec ...')
      }
  }
  </code></pre>
  
  <p>But it's not working properly as the script keeps running and loops all over the for loop even though an error occured in the await...</p>