MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 message listeners added. Use emitter.setMaxListeners() to increase limit
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 thanks for bringing this up. We're aware of the EventEmitter memory leak and have a fix coming for it soon.
This seems to have been fixed in 1.3, so I think we can close this.
Still getting the same error
Also getting this with node v8.8.1
any updates on this? getting the same warning
+1
I am also getting this issue currently.
Is there a workaround suggested?
@dlumma Does it use less memory if i deploy chromeless to aws?
Getting the same warning
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.