Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase eventEmitter.maxListeners in inpage script #5493

Closed
danfinlay opened this issue Oct 10, 2018 · 3 comments · Fixed by #5537
Closed

Increase eventEmitter.maxListeners in inpage script #5493

danfinlay opened this issue Oct 10, 2018 · 3 comments · Fixed by #5537

Comments

@danfinlay
Copy link
Contributor

Seems that our new .subscribe() support has introduced an event listener warning to our inpage script:

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

Reported here.

@bdresser
Copy link
Contributor

fwiw i've seen this error intermittently for the past several months

@hodlbank
Copy link

hodlbank commented Oct 11, 2018

Can confirm.
Our DApp having page with list of "receipts", each receipt watches a contract event.
When there are more than 10 receipts this error happens.

Stack trace (roughly):

EventEmitter?.addListener()
RequestManager.setProvider()
???.packageInit()
new a.web3.eth.Contract()

@hodlbank
Copy link

hodlbank commented Oct 12, 2018

Solution for our DApp is to increase maxListeners of currentProvider upon provider initialization:

// typescript
private tuneUpProvider(provider: Provider): void {
    let providerEE = provider as any;
    if (typeof providerEE.setMaxListeners == 'function') {
      providerEE.setMaxListeners(999);
    }
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants