First run of the day is running much slower (puppeteer JS)

Viewed 18

I am using puppeteer and puppeteer-screen-recorder in a JS node program. when Im running the program in the morning for the first time after the night (or after a few hours from the last run), the run time is much slower than all the runs after it. first run:

Execution time: 12.819 Sec

All the other runs with the same inputs are taking about 6 seconds. the problem is that the output is different too. Im taking a screen capture of about 5 seconds. In the first run the recording starts about half a second after the website laucnhed and in all of the other runs it works perfectly.

part of the JS code:

  const browser = await puppeteer.launch({
      defaultViewport: null,
      args: [
        "--no-first-run",
        "--ash-no-nudges",
        "--disable-web-security", // disable cors
      ]
  });

  const page = await browser.newPage();
  const url = html_file_name; //  file:\\.......html
  const recorder = new PuppeteerScreenRecorder(page);
  
  await page.goto(url,{ waitUntil: 'domcontentloaded', timeout: 30000});
  await recorder.start(output_file); 
  await sleep(time_need_to_record * 1000);
  await recorder.stop();

any ideas?

Thanks.

0 Answers
Related