Coder Social home page Coder Social logo

Comments (4)

thomasdondorf avatar thomasdondorf commented on May 19, 2024 2

Thanks for reporting, this definitely needs investigation.

from puppeteer-cluster.

hashtafak avatar hashtafak commented on May 19, 2024 1

On each launch() function called, 4 events have been adding to NodeJS's process

const listeners = [helper.addEventListener(process, 'exit', killChrome)];
if (handleSIGINT)
    listeners.push(helper.addEventListener(process, 'SIGINT', () => {
        killChrome();
        process.exit(130);
    }));
if (handleSIGTERM)
    listeners.push(helper.addEventListener(process, 'SIGTERM', gracefullyCloseChrome));
if (handleSIGHUP)
    listeners.push(helper.addEventListener(process, 'SIGHUP', gracefullyCloseChrome));

When puppeteer-cluster launch a lot of Worker, NodeJS will show MaxListenersExceededWarning error

FYI: https://nodejs.org/api/events.html#events_eventemitter_defaultmaxlisteners

By default, a maximum of 10 listeners can be registered for any single event.
.. EventEmitters will print a warning if more than 10 listeners are added for a particular event. This is a useful default that helps finding memory leaks.

You can easily disable this warning by using process.setMaxListeners(n) with n=20 in your case or more.

puppeteer/puppeteer#594

For advanced use, you can remove all event listeners exit added by Puppeteer. And do some stuff like killChrome() and gracefullyCloseChrome() by yourself.

Note that 3 events SIGINT, SIGTERM, SIGHUP can be disabled in launch() options. Work in my case

const browser = await puppeteer.launch({
    handleSIGINT = false,
    handleSIGTERM = false,
    handleSIGHUP = false,
});

from puppeteer-cluster.

bangbambang avatar bangbambang commented on May 19, 2024

Note that 3 events SIGINT, SIGTERM, SIGHUP can be disabled in launch() options. Work in my case

const browser = await puppeteer.launch({
    handleSIGINT = false,
    handleSIGTERM = false,
    handleSIGHUP = false,
});

FYI, most process managers use at least one of those signals to "ask" the process to terminate nicely. For example, systemd would send SIGTERM followed by SIGINT 90 seconds later (default behavior). Disabling them without explicitly call killChrome or gracefullyCloseChrome may spawn zombie processes.

raising max listeners to match worker count would be the safest workaround. As an added bonus, you could register additional listeners to do resource cleanup when the signal received.

from puppeteer-cluster.

mastershaig avatar mastershaig commented on May 19, 2024

For me removing '--single-process', from args fixed the issue

puppeteerOptions: {
    headless: true,
    args: [
        // '--single-process',
    ],
}

from puppeteer-cluster.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.