trustwallet / trust-wallet-ios

:iphone: Trust - Ethereum Wallet and Web3 DApp Browser for iOS
https://trustwallet.com
GNU General Public License v3.0
1.52k stars 721 forks source link

[failed listen ethereum event] warning: possible EventEmitter memory leak detected. #718

Open huahuayu opened 6 years ago

huahuayu commented 6 years ago

Hi, we spend whole day debugging an issue in our Dapp (etherwow.io), and finally, find the issue may be related to trust wallet. We add debug icon on the page and found error as below: image

Our dapp has two versions, one on testnet(gaowenbao.net , do not support https), one on mainnet (etherwow.io). The frontend & smart contract is exactly same for both versions.

Now the problem is: in testnet(gaowenbao.net): our dapp works well both in metamask(pc) and in trust wallet. in mainnet(etherwow.io): our dapp works in metamask(pc), BUT not work in trust wallet. Or, to be more accurate, in mainnet we can't listen to LogBet event from solidity and got issue as the picture shows.

How to reproduce: step1: try gaowenbao.net in testnet(ropsten) by metamask and trust wallet(since it's in Chinese please use google translate for your convenience). Just choose one option and bet. Waiting for a while to generate the random num. You will find metamask & trust wallet both works fine. step2: try etherwow.io in mainnet by metamask, it cost real eth, just bet 0.1 eth will be fine. You will find
metamsk works fine. step3: try etherwow.io/_debug(mainnet ) in trust wallet. Choose to bet 0.1 eth, and wait for a while, click the setting button to see the logs image you will get a warning like this "warning: possible EventEmitter memory leak detected. ", for this reason, our dapp can't listen to LogBet event. We do lots of tests and confirm it's trust wallet's problem, please check what's the problem.

our js code for your investigation: https://github.com/hs-tqb/ethergo/blob/master/pages/index.vue smart contact: https://etherscan.io/address/0x2d05359a51ca13c4ac5f4437585afaf5bf2050f9#code

Thank you!

vikmeup commented 6 years ago

Use web3 provider only sign transactions and messages, the rest use your provide to interact with a blockchain, that’s the best practice

huahuayu commented 6 years ago

@vikmeup thank you for your suggestion, but with the same front-end code and same smart contract, testnet works great in trust wallet. When comes to mainnet, the problem occurs, If you have tried, you may see the issue. what's the difference on earth?

vikmeup commented 6 years ago

@huahuayu can you telegram me @vikmeup? let's figure this out

vikmeup commented 6 years ago

@huahuayu take a look at deep linking with Trust!: https://medium.com/@trustwallet/mobile-dapps-with-deep-linking-and-trust-wallet-6a4712b9b9a4

vikmeup commented 6 years ago

@mishfit do you think this fixes this issue as well?

mishfit commented 6 years ago

It's possible, when the trust web3 provider is running wss (websockets) it emits data events and behaves like an EventEmitter...when it is using https it doesn't emit those events.

I'd have to run it (or even better, we can add a test for this to the provider test suite)