puppeteer: [Bug]: Chrome browser requests leak memory when running with Puppeteer

Bug description

Steps:

  1. Load a page in Chrome using puppeteer
  2. Start executing requests from that page.
  3. After about 30 seconds, you will see Chromium Helper (Renderer) memory starting to tick up by ~ 0.5 megabytes/second

Seems to happen on Mac and Windows. Doesn’t seem to happen in Firefox. Doesn’t seem to happen if you disconnect puppeteer after setup.

Reproduction (run in node, requires Puppeteer):

require('http')
  .createServer(function (request, response) {
    console.log('received request');
    response.end('booyah');
  })
  .listen(20547);

const runPuppeteer = async () => {
  const browser = await require('puppeteer').launch();
  const page = await browser.newPage();

  const html = `<!DOCTYPE html>
<html lang="en">
  <head></head>
  <body>
    <script>
      setTimeout(async () => {
        console.log('starting fetching');
        while (true) {
          await fetch('http://localhost:20547/anything', {mode: 'no-cors'});
        }
      }, 100);
    </script>
  </body>
</html>
`;
  await page.setContent(html);
};

runPuppeteer();

// Make run forever
setTimeout(() => {
  console.log('done');
}, 100000000);

Thanks!

Puppeteer version

19.2.2, think it is present in older versions too

Node.js version

18.11.0

npm version

8.19.2

What operating system are you seeing the problem on?

macOS

Configuration file

No response

Relevant log output

No response

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 3
  • Comments: 17

Most upvoted comments

Each open tab requires at least 30-40 MB of memory, so you cannot open 30 pages at the same time on that server. You need to make sure that you only process 1 (or N) pages at a time and queue other HTTP requests.