How to locate the source of my memory leak?

走远了吗. 提交于 2020-01-16 12:00:14

问题


I've got a Puppeteer project where I'm trying to record and analyze the structure of some online forms. I expect to see a list of each form input's name attribute values printed to the console. But instead, I get the following error.

(node:4014) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 Symbol(Events.FrameManager.FrameDetached) listeners added to [FrameManager]. Use emitter.setMaxListeners() to increase limit

How can I locate the source of the memory leak or otherwise comply with the error warning message?

(async () => {
  const browser = await puppeteer.launch();
  const page = await browser.newPage();
  domains.forEach( domain => {
    const exts = [ null, ...contactExtensions, ];
    exts.forEach( async ext => {
      const a = [ domain, ext, ];
      const url = ext ? a.join(joiner) : domain;
      await page.goto(url);
      const pageFunction = $posts => {
        const data = [];
        $posts.forEach( $post => {
          data.push($post.name);
        });
        return data;
      };
      const data = await page.$$eval( 'form input', pageFunction, );
      console.log('data', data,);
    });
  });
  await browser.close();
})();

来源:https://stackoverflow.com/questions/59194671/how-to-locate-the-source-of-my-memory-leak

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!