Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

168
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda