Replies: 1 comment
-
Update: So after banging my head against the wall repeatedly trying to fix this by all means necessary I ultimately had to redefine the saying all together. After hours/days of huffing and puffing I figured I only had one option left: reverse engineer by process of elimination. So, I have recreated the project however this time I chose to build the front end in React-proper instead of the Next-framework. Also, I chose to use a different router entirely (I used React-Router-Dom instead of the Next/Link router). To provide some perspective, my steps so far:
Now, although I have little coding experience I do think I can at least point my finger in the right direction >> IMHO the culprit was the Next/Link router (which in the NextJS framework seems to be the go-to router). After some reading into how the Next/Link router works it seems as tho it really likes to re-render all components every chance it gets. Keeping that in mind, I get a vague feeling that at every re-render the ConnectButton from the Web3UIKit (and/or in combination with React-DOM) keeps adding a listener at every step. If that holds true, the error should come up at every 11 scrolls through the pages ( and that is what the 'evidence' shows ). In contrast, the React-Router-DOM allows for nesting and dynamic routing which, in turn, allows us to choose which components to re-render and which it should not. This way we don't add any listeners at every step of the way. Being fully aware that I am Bronze League at best I just want to share my findings as I need someone that actually knows what they are talking about to verify what I am saying is even remotely possible OR true. That being said: sharing is caring. Disclaimer: this is the first place I came to share my thoughts as many more issues may arise from the current packages I am using so reader beware. Thanks for reading, Patrick |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi all!
I am continuously running into a MaxListeners Exceeded issue in my project and I cannot find the solution to it. The problem presents itself when browsing between pages in the navBar a few times: after a couple of clicks the console notifies the Maxlisteners issue:
Verbatim Error in console:
MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 accountChanged listeners added. Use emitter.setMaxListeners() to increase limit.
I find this weird as the coding does not include anything special and I cannot find the rootcause of this. After scouring StackOverflow and the like I have seen some people having similar issues but no solution goes further than setting the Maxlisteners. The reason I am reluctant to go that way is that people have compared this 'fix' with sweeping dirt under the rug and is therefore not the ideal solution.
I have created a seperate barebones project on Github that only has the minimum required packages on it to try and isolate the problem. It seems as though the web3UIKit, React, Moralis and/or Next don't play well with eachother however I lack the expertise to determine this 100%. The notification mentions 'accountChanged' which makes me think the connectbutton from web3UIkit might be the culprit. On the other hand the listeners that are added seem to mostly refer to node modules/react-dom.
My question(s) to you is: have you ever seen this error, can you find the cause of this problem and/or do you know of a solution to counteract this problem all together.
I will share the code below and a GitHub clone for your convenience. I will be forever in your debt if you can help me.
github clone: https://github.com/deAgora/maxlisteners.git
_app.js
Index.js
Page1.js
Component Header.js
Component: Navbar.js
Package.json
Beta Was this translation helpful? Give feedback.
All reactions