Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

MaxListenersExceededWarning encountered when running with Web3 #267

Closed
adrianmcli opened this issue Dec 30, 2018 · 3 comments
Closed

MaxListenersExceededWarning encountered when running with Web3 #267

adrianmcli opened this issue Dec 30, 2018 · 3 comments
Assignees
Labels

Comments

@adrianmcli
Copy link
Contributor

For more detailed history: web3/web3.js#1648

When running Ganache provider (for my tests) and then subsequently interacting them with Web3.js, I get warnings like the following:

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

According to this specific comment, the issue seems to be due to the Ganache Provider.

Interestingly, @cgewecke suppressed these warnings in Truffle in this PR: trufflesuite/truffle#1088

Not exactly sure if this belongs here, but I believe it is worth the investigation.

@mikeseese mikeseese self-assigned this Jan 4, 2019
@mikeseese
Copy link
Contributor

I can reproduce this by running the test/call test every time.

Here is a stacktrace of the warning:

(node:11601) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 data listeners added. Use emitter.setMaxListeners() to increase limit
    at _addListener (events.js:243:17)
    at Provider.addListener (events.js:259:10)
    at RequestManager.setProvider (/.../ganache-core/node_modules/web3-core-requestmanager/src/index.js:98:23)
    at Object.packageInit (/.../ganache-core/node_modules/web3-core/src/index.js:57:33)
    at Contract (/.../ganache-core/node_modules/web3-eth-contract/src/index.js:63:10)
    at new Contract (/.../ganache-core/node_modules/web3-eth/src/index.js:148:22)
    at Contract.clone (/.../ganache-core/node_modules/web3-eth-contract/src/index.js:560:12)
    at Object.contractDeployFormatter (/.../ganache-core/node_modules/web3-eth-contract/src/index.js:878:57)
    at Object.callback (/.../ganache-core/node_modules/web3-core-method/src/index.js:323:70)
    at sendTxCallback (/.../ganache-core/node_modules/web3-core-method/src/index.js:487:29)
    at /.../ganache-core/node_modules/web3-core-requestmanager/src/index.js:147:9
    at Object.intermediary [as callback] (/.../ganache-core/lib/provider.js:116:5)
    at self.engine.sendAsync (/.../ganache-core/lib/provider.js:171:12)
    at /.../ganache-core/node_modules/web3-provider-engine/index.js:152:9
    at /.../ganache-core/node_modules/async/internal/once.js:12:16
    at replenish (/.../ganache-core/node_modules/async/internal/eachOfLimit.js:61:25)
    at /.../ganache-core/node_modules/async/internal/eachOfLimit.js:71:9
    at eachLimit (/.../ganache-core/node_modules/async/eachLimit.js:43:36)
    at /.../ganache-core/node_modules/async/internal/doLimit.js:9:16
    at end (/.../ganache-core/node_modules/web3-provider-engine/index.js:127:5)
    at /.../ganache-core/lib/statemanager.js:271:5
    at /.../ganache-core/lib/blockchain_double.js:1105:9
    at process._tickCallback (internal/process/next_tick.js:61:11)

@mikeseese
Copy link
Contributor

The only correct path forward within ganache (I believe that this is really a problem in web3.js which is adding listeners a little haphazardly) is to overload the on() function in the ganache provider and do some stuff to prevent the warning. Suppressing the warnings like the truffle PR is definitely not a great approach

@mikeseese
Copy link
Contributor

Seems like this issue is being dropped

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

Successfully merging a pull request may close this issue.

2 participants