Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

164
Views
How to handle concurrent requests with Puppeteer?

I have problem with EventEmitter memory leak detected

I have function that starts the browser like this

async function startBrowser() {
const revisionInfo = await browserFetcher.download("901912");
  const browser = await puppeteer.launch({
    executablePath: revisionInfo.executablePath,
    args: [
      "--no-sandbox",
      "--disable-gpu",
      "--disable-dev-shm-usage",
      "--disable-setuid-sandbox",
      "--no-first-run",
      "--no-zygote",
      "--single-process",
    ],
  });
  const page = await browser.newPage();
  return { browser, page };
}

One of my functions maps through number of items like

const work = (stuff) => {
    const workTodo = stuff.map(item = {
     setTimeout(() => {
      anotherFunction(some params)
     }, some time variable all different seconds
     }
     await Promise.all(workTodo);


}

and in the anotherFunction()

    anotherFunction(someParams) {
    const { browser, page } = await startBrowser();
    try {
    await browser.newPage();
    await page.goto('stuff');
    await page.waitForSelector('stuff');
    await page.click('stuff');

    await page.close();
    await browser.close();

   } catch (error) {
     console.log('error', error);
    return 
   }

The logic in anotherFunction() works about 70-80 % of the time, but sometimes it gets timeout exceeded at waitForSelector calls and sometimes I get memory leak errors.

Am I creating too many browsers ? and not closing properly?

Can someone who knows puppeteer tell me what Im doing wrong?

about 4 years ago · Santiago Gelvez
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!