title: `Error: Evaluation failed: Object` and `Error: Protocol error (Network.getResponseBody): Request content was evicted from inspector cache`
body: <ul>
  <li>I am trying to download .ts files of different videos using Puppeteer.</li>
  <li>I do this by keeping track of all the .ts requests (which I invoke myself) and then saving/appending all their responses.</li>
  <li>However, sometimes <code>UnhandledPromiseRejectionWarning: Error: Evaluation failed: Object</code> occurs, which points to <code>page.evaluate</code>, out of no where. Although, I suspect this mostly happens when lots of .ts files are getting processed.</li>
  <li>Also, similarly, whenever there is a large file with lots of .ts, <code>UnhandledPromiseRejectionWarning: Error: Protocol error (Network.getResponseBody): Request content was evicted from inspector cache</code> occurs. </li>
  </ul>
  
  <p>Any suggestions on how I could -</p>
  
  <ol>
  <li><p>Solve the <code>page.evaluate</code> issue.</p></li>
  <li><p>Clear the inspector cache when I am done with particular requests/data and make Puppeteer save a large number of .ts files. </p></li>
  </ol>
  
  <pre class="lang-js prettyprint-override"><code>/* This whole code is inside an async function */
  
  /*    .... code for finding array ts ....      */
  
  let requests = [], prs = [];
  
  page.on('request', req =&gt; {
      if(req.url().endsWith('.ts')){
          requests.push(req);
      }
  });
  
  /* 
      ts[i].ts contains all the links to a stream/video's .ts files
      ts[i].filename contains the name of that video
  */
  
  for (i = 0; i &lt; ts.length; i++) {
      for(const ele of ts[i].ts){ 
          // Not writing await is on purpose; for saving all the pending promises
          let x = page.evaluate(async (link, file) =&gt; {
  
              // jQuery is included in the page itself
              return $.ajax({
                  url : link,
                  headers : {"custom" : file}
              });
          }, ele, ts[i].filename);
  
          prs.push(x);
      }
  
      // This makes request.response() be filled
      await Promise.all(prs);
  
      for(let req of requests){
          let res = await req.response().buffer();
          let fname = req.headers().customHeader;
  
          // Data written to relevant file
          fs.appendFileSync(fname, res);  
      }
  
      prs = [];
      requests = [];
  }
  </code></pre>