useDApp icon indicating copy to clipboard operation
useDApp copied to clipboard

TypeError: connector.off is not a function

Open gwendall opened this issue 4 years ago • 4 comments

I get this error whenever I want to disconnect a user. Any idea how to fix that ?

Unhandled Runtime Error
TypeError: connector.off is not a function

Call Stack
eval
node_modules/@usedapp/core/node_modules/@web3-react/core/dist/core.esm.js (496:0)
HTMLUnknownElement.callCallback
node_modules/react-dom/cjs/react-dom.development.js (3945:0)
Object.invokeGuardedCallbackDev
node_modules/react-dom/cjs/react-dom.development.js (3994:0)
invokeGuardedCallback
node_modules/react-dom/cjs/react-dom.development.js (4056:0)
flushPassiveEffectsImpl
node_modules/react-dom/cjs/react-dom.development.js (23543:0)
unstable_runWithPriority
node_modules/react-dom/node_modules/scheduler/cjs/scheduler.development.js (468:0)
runWithPriority$1
node_modules/react-dom/cjs/react-dom.development.js (11276:0)
flushPassiveEffects
node_modules/react-dom/cjs/react-dom.development.js (23447:0)
eval
node_modules/react-dom/cjs/react-dom.development.js (23324:0)
workLoop
node_modules/react-dom/node_modules/scheduler/cjs/scheduler.development.js (417:0)
flushWork
node_modules/react-dom/node_modules/scheduler/cjs/scheduler.development.js (390:0)
MessagePort.performWorkUntilDeadline
node_modules/react-dom/node_modules/scheduler/cjs/scheduler.development.js (157:0)

gwendall avatar Sep 02 '21 09:09 gwendall

Could you provide some reproduction of that error?

nezouse avatar Sep 02 '21 22:09 nezouse

@nezouse Ran into this as well. The issue comes from the EventEmitter implemented by AbstractConnector not always being a real EventEmitter. It will have some properties of the Node EventEmitter class but not all of them, including the off method.

I blindly tried installing the most recent events package and that solved the issue. I wonder if this has to do with webpack5 not polyfilling events and other node packages.

It doesn't look like @web3-react/core explicitly pins events as a dependency, so I'm willing to bet that's what it is.

Synvox avatar Dec 10 '21 05:12 Synvox

@nezouse Ran into this as well. The issue comes from the EventEmitter implemented by AbstractConnector not always being a real EventEmitter. It will have some properties of the Node EventEmitter class but not all of them, including the off method.

I blindly tried installing the most recent events package and that solved the issue. I wonder if this has to do with webpack5 not polyfilling events and other node packages.

It doesn't look like @web3-react/core explicitly pins events as a dependency, so I'm willing to bet that's what it is.

I've tried this and it doesn't seem to do anything other than change the error to:

TypeError: _.off is not a function

Jakkc avatar Aug 05 '22 12:08 Jakkc

I tried reproducing this on recent version of useDApp, no luck. The error might have been fixed along the way? Here is an example of web3modal usage in useDApp, where I can connect and disconnect a user without any error.

https://example.usedapp.io/web3modal

rzadp avatar Aug 26 '22 14:08 rzadp