chromeless icon indicating copy to clipboard operation
chromeless copied to clipboard

MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 message listeners added. Use emitter.setMaxListeners() to increase limit

Open aml11 opened this issue 8 years ago • 11 comments

When reusing the same Chromeless proxy object I get MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 message listeners added. Use emitter.setMaxListeners() to increase limit

This is consistent and can be easily reproduced using this snippet:

import {Chromeless} from 'chromeless'
declare var document: any;

async function run() {
    const remote = {};
    const chromeless = new Chromeless(
        {
            remote: {
                endpointUrl: 'XXXXX',
                apiKey: 'XXXXX'
            },
        }
    );
    for (let site of ["https://google.com", "https://amazon.com", "https://apple.com", "https://google.com", "https://amazon.com", "https://apple.com"]) {
        const title = await chromeless
            .goto(site)
            .evaluate(() => {
                return document.title
            });
        console.log(title) // prints local file path or S3 url
    }


    await chromeless.end()
}

run().catch(console.error.bind(console))

Will output:

Google
Amazon.com: Online Shopping for Electronics, Apparel, Computers, Books, DVDs & more
Apple
Google
(node:8059) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 message listeners added. Use emitter.setMaxListeners() to increase limit
    at _addListener (events.js:281:19)
    at MqttClient.addListener (events.js:298:10)
    at /Users/amir/dev/test/testVideosFb/node_modules/chromeless/dist/src/chrome/remote.js:186:47
    at MqttClient.subscribe (/Users/amir/dev/test/testVideosFb/node_modules/mqtt/lib/client.js:484:5)
    at /Users/amir/dev/test/testVideosFb/node_modules/chromeless/dist/src/chrome/remote.js:185:43
    at Promise (<anonymous>)
    at RemoteChrome.<anonymous> (/Users/amir/dev/test/testVideosFb/node_modules/chromeless/dist/src/chrome/remote.js:184:35)
    at step (/Users/amir/dev/test/testVideosFb/node_modules/chromeless/dist/src/chrome/remote.js:32:23)
    at Object.next (/Users/amir/dev/test/testVideosFb/node_modules/chromeless/dist/src/chrome/remote.js:13:53)
    at fulfilled (/Users/amir/dev/test/testVideosFb/node_modules/chromeless/dist/src/chrome/remote.js:4:58)
Amazon.com: Online Shopping for Electronics, Apparel, Computers, Books, DVDs & more
Apple

I deployed version Chromeless version 1.0.1 (due to #99 ) both locally and remotely.

aml11 avatar Aug 06 '17 13:08 aml11

@aml11 thanks for bringing this up. We're aware of the EventEmitter memory leak and have a fix coming for it soon.

adieuadieu avatar Aug 06 '17 14:08 adieuadieu

This seems to have been fixed in 1.3, so I think we can close this.

skunkwerk avatar Nov 04 '17 22:11 skunkwerk

Still getting the same error

zelphir avatar Nov 28 '17 16:11 zelphir

Also getting this with node v8.8.1

davidworkman9 avatar Dec 04 '17 16:12 davidworkman9

any updates on this? getting the same warning

Raidus avatar Dec 12 '17 20:12 Raidus

+1

achyutjhunjhunwala avatar Dec 14 '17 16:12 achyutjhunjhunwala

I am also getting this issue currently.

dlumma avatar Dec 22 '17 23:12 dlumma

Is there a workaround suggested?

dlumma avatar Dec 22 '17 23:12 dlumma

@dlumma Does it use less memory if i deploy chromeless to aws?

Nisthar avatar Jan 12 '18 16:01 Nisthar

Getting the same warning

beyer-martin avatar Jun 05 '18 20:06 beyer-martin

I solved this warning with next code: require('events').EventEmitter.defaultMaxListeners = 30;. But I still have performance issue (my script executing during 20-30 seconds on AWS) as it was with the warning.

dragg avatar Jun 07 '18 06:06 dragg