SOLVED

Multiple forms causing possible EventEmitter memory leak console warning

Go to solution
Anonymous
Not applicable

Multiple forms causing possible EventEmitter memory leak console warning

I am working on a project that entails putting two different marketo forms on the same page.  This is resulting in the following console error:

     (node) warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit.

The console trace points to marketo's form2 js file.  I have even tried removing every event listener on my end just to be sure.

Anyone have any ideas?

Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Multiple forms causing possible EventEmitter memory leak console warning

You have to link to your code.

The error is pretty accurate: a userland event management library (EventEmitter, developed I think originally by Joyent) is used by Forms2. Unlike native browser events, EE tries to be aware of when a stack limit is reached, sometimes creating unnecessary worry.

View solution in original post

3 REPLIES 3
SanfordWhiteman
Level 10 - Community Moderator

Re: Multiple forms causing possible EventEmitter memory leak console warning

You have to link to your code.

The error is pretty accurate: a userland event management library (EventEmitter, developed I think originally by Joyent) is used by Forms2. Unlike native browser events, EE tries to be aware of when a stack limit is reached, sometimes creating unnecessary worry.

Anonymous
Not applicable

Re: Multiple forms causing possible EventEmitter memory leak console warning

Turned out there were too many calls to MktoForms2.whenReady().

SanfordWhiteman
Level 10 - Community Moderator

Re: Multiple forms causing possible EventEmitter memory leak console warning

Right, you can almost always combine those event listeners (just seek the form ID in the listener).