Answers for "(node:14372) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 SIGHUP listeners added to [process]. Use emitter.setMaxListeners() to increase limit"

1

(node:13048) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 post listeners added to [EventEmitter]. Use emitter.setMaxListeners() to increase limit

const emitter = new EventEmitter()
emitter.setMaxListeners(100)
// or 0 to turn off the limit
emitter.setMaxListeners(0)
Posted by: Guest on July-07-2021
2

(node:14372) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 SIGHUP listeners added to [process]. Use emitter.setMaxListeners() to increase limit

/*

https://github.com/puppeteer/puppeteer/issues/594#issuecomment-325919885
*/
const puppeteer = require('puppeteer')
const R = require('rambda')

process.setMaxListeners(Infinity); // <== Important line

const resolution = {
  x : 1920,
  y : 1080,
}
// ...
Note: you don't need to launch browser just to create a page. Instead, you can open multiple pages in the same browser:

const puppeteer = require('puppeteer')
const R = require('rambda')

const resolution = {
  x : 1920,
  y : 1080,
}

const args = [
  '--disable-gpu',
  `--window-size=${ resolution.x },${ resolution.y }`,
  '--no-sandbox',
]

let browser;

const work = async () => {
  const page = await browser.newPage()

  const url = 'https://ilearnsmarter.com/learning-meme'

  await page.setViewport({
    width  : resolution.x,
    height : resolution.y,
  })

  await page.goto(url, { waitUntil : 'networkidle' })
  await page.close();
}

const fn = async () => {
  browser = await puppeteer.launch({
    headless     : true,
    handleSIGINT : false,
    args         : args,
  })
  const promised = R.range(0, 12).map(() => work())
  await Promise.all(promised)
  browser.close()

  console.log('DONE')
}

fn()
Posted by: Guest on April-15-2020

Code answers related to "(node:14372) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 SIGHUP listeners added to [process]. Use emitter.setMaxListeners() to increase limit"

Code answers related to "Javascript"

Browse Popular Code Answers by Language