-
Notifications
You must be signed in to change notification settings - Fork 5k
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
MaxListenersExceededWarning when sending contract (v1.0.0-beta.33) #1648
Comments
I have the same issue, have you found a solution yet? |
@jackno Is this issue still there with beta-34? |
I've got the same issue with beta-35. |
This problem relates to
|
@xpepermint I dug into this a little bit with the Ganache team, and it seems that the problem is that every request in Web3.js seems to add on another listener on the same "data" event, instead of having a master listener. |
Changes: - Use Web3.utils instead of importing eth.js in multiple files - Add timeout before tests start -- this is because now startup takes too long - Add some config options - Suppress node warning coming from a web3 bug. See: web3/web3.js#1648
Same problem here. @adrianmcli Could you be somewhat more specific please? |
This is a problem of the ganache provider and not one of the Web3.js library. Please open an issue there for solving it. |
No it is a bug of |
Same here. |
Is this still an issue for everyone or has a fix been made for this? |
@eggplantzzz no fix still. The problem is with how Web3.js attaches listeners haphazardly. I haven't looked at this in a few months, but I recall that a new listener is attached every time a constructor of some object is created. But it should really just be a singleton that each instance refers to. I know that's pretty vague, but that's the only recollection I have. I'll have to dig in to this again later this month. Or maybe someone else can. |
Let's unpack this further, this is the stack trace I get when I enable
Do note that this is a project that is relying on Beta35, but I believe the cause is probably the same. Whenever a new sendTx is created during deployment, This also seems to happen when just creating new contract instances:
The real question is why |
I'm also seeing the same memory leak generated by the second stack trace when creating multiple contract instances connected to the MetaMask's provider. It turns out that web3 v1.2.1 adds a new listener each time a new contract instance is created: Maybe this issue is worth to be reopened and investigated further? For our Dapp, this is a critical bug since we create a lot of contract instances through the lifetime of the application, and we cannot cache them. A related issue in truffle: trufflesuite/truffle#1942. |
@nivida Can you re-open this issue? I think everyone is in agreement that this is not solved (and the problem is not with Ganache). |
@nivida I hope I'm not overstepping -___- "with great power comes great responsibility"? |
@gnidan Thanks for re-opening this issue. I had the same bug in the 2.x branch and already fixed it. We will fix it as soon as possible in the 1.x branch. |
FYI: When git cloning and building the latest version of web3 from the 1.x branch with #3190 merged, I still get the MaxListenersExceededWarning. |
@wbt We've seen this go away in our E2E tests but they are relatively modest in scope...what needs to be done to trigger the warning? |
@cgewecke Does trufflesuite/truffle#1942 help? |
This is now configurable. If you're using Websockets and calling |
Situation: When I send a deployed contract using
contract.deploy().send()
, the command line prints a warning:Edit (14 April 2020): removed unnecessary information
The text was updated successfully, but these errors were encountered: