Eventemitter leak and plotly_afterplot


I am updating a surface plot using extendTraces about 100 times or so. I want to keep users from clicking to start a new plot before the old one is done, so I am using this:

plotDiv.on(‘plotly_afterplot’, function(){

if (plotDone == true) {
	plotDone = false;
	document.getElementById("message").value = "Ready ...";	


This appears to work OK, but is called after every call to extendTraces. Eventually I get the “possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit.” message and my machine starts to work hard.

Is there a way to free up the memory this is causing or, better, is there a way to turn on afterplot only when I know that I am close to the end?

Thanks for any help!


I am actually using scatter3D, not surface.


Maybe you can try using plotDiv.once(‘plotly_afterplot’, function(){} instead of .on


Thanks Etienne - .once works just fine!