blocknative / web3-onboard

Client library to onboard users to web3 apps
https://onboard.blocknative.com/
MIT License
854 stars 510 forks source link

MaxListenersExceededWarning when I try to init contract in Goerli chain. #1631

Closed Chocopieca closed 1 year ago

Chocopieca commented 1 year ago

Current Behavior

I init web3 instance by using web3-onboard/core with Goerli chain in options. After that I try to init my smart contract by this instance.

When I push my connect button, I get MaxListenersExceededWarning in my console. image MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 101 "message" listeners added. Use emitter.setMaxListeners() to increase limit. And I get error TypeError: Resolution is not a constructor: image

After that tab freezes, my vue dev tools don't updates and somtimes dev tools enables debug mode.

My logs: localhost-1680776884854.log

Expected Behavior

No response

Steps To Reproduce

  1. I init onboarding from web3-onboard/core with this options: { wallets: [injected, fortmatic], chains:{ id: "0x5", token: "ETH", label: "Goerli", rpcUrl: "https://eth-goerli.public.blastapi.io", }, appMetadata: { name: "MyProject", icon: logo, logo: logo, description: "Project using Onboard", recommendedInjectedWallets: [ { name: "Coinbase", url: "https://wallet.coinbase.com/" }, { name: "MetaMask", url: "https://metamask.io" }, ], }, }
  2. Toggle connectWallet and setChain with value 5
  3. After gat web3 instance I try to init contract by eth.Contract with abi and address.
  4. I catch my problem.

What package is effected by this issue?

@web3-onboard/core

Is this a build or a runtime issue?

Runtime

Package Version

9.4.0

Node Version

v16.17.1

What browsers are you seeing the problem on?

No response

Relevant log output

No response

Anything else?

It happans on all browsers. I tried to increase the listeners limit but unfortunately, it is not working. If I use another chain, this problem does not occur.

Sanity Check

lnbc1QWFyb24 commented 1 year ago

Hey @Chocopieca the Resolution is not a constructor error might be the problem here. Could you try turning it off via the init options to onboard to confirm that is the case or not:

const onboard = web3Onboard({
  // .... other options
  connect: {
    disableUDResolution: true
  }
})

Also which bundler are you using with Vue? If you are using Vite, check out our docs for Vite build environments as this is likely an issue with module resolution.

Chocopieca commented 1 year ago

I set disableUDResolution to true but it doesn't resolve my problem. I steel catch MaxListenersExceededWarning.

I use vite build evironments from your doc and catch "node_modules/crypto-js/core.js:53:30: ERROR: Could not read from C:/path-for-project/crypto-browserify". After I set alias "crypto: 'crypto-browserify'" build script try to require crypto in this path which doesn't exist. image Am I doing something wrong? My problem still happens.

For Goerli test I use a common usdt contract from google search.

Adamj1232 commented 1 year ago

@Chocopieca have you had a look at our Vite example project here?

Chocopieca commented 1 year ago

@Adamj1232 Yes, I tried this example and still catch Listeners warning and tab freeze. When I connect to Metamask, everyone is going well, but when I initiate usdt contract I catch this problem.

I tried to use vite expended example from doc and I tried to use vite code from react project. I rework my code with example from vue3 project. Now I use sepolia chain, it works fine, but I want to use goerli in the future.

Adamj1232 commented 1 year ago

@Chocopieca Might try a look at #1645 for possible resolution. Looks like you are missing dep. Also, the contract should have no affect on web3-onboard as we do not alter or perform any actions on contract calls.

Chocopieca commented 1 year ago

@Adamj1232 Thank you for the reference. No, problems happen with all contracts on Gorile.

Adamj1232 commented 1 year ago

@Chocopieca If you are able to send a stackblitz or way to reproduce this issue that would be helpful as I am unable to reproduce this locally. We don't do any contract interaction manipulation so I dont think this is an issue within onboard. Can you confirm all dev-deps have been added?

SpiritusDeos commented 1 year ago

Working well on my side - if I can help tell me @Adamj1232 using also Vite and Vue3

ejc8 commented 1 year ago

Closing this issue - thanks all