MaxListenersExceededWarning when multiple


I am trying to read multiple IPFS files, to do some benchmarking, like this :

  for(i=0;i<100;i++) {
    const cid = cids[i]
    for await (const chunk of {

It throws a MaxListenersExceededWarning when i=10 and I imagine this is due to the opens too many sockets.
What would be the right way to read IPFS files sequentially or to make this limit higher ? thanks

I’d imagine this is a limitation of the web browser. I’m assuming the limit would be higher using straight nodejs.

It is a bit surprising though, as I would have thought going in sequence like that would work fine :thinking:

By googling “MaxListenersExceededWarning setMaxListeners” and also the fact that you’re saying the 11th one is the problem, it implies somewhere in the code there’s an EventEmitter that needs “setMaxListeners” called to allow more than 10. But I really don’t know what I’m talking about… I just did some googlin’. :slight_smile:

1 Like

Not a limitation of the web browser, as this code runs in node.js
I’ve googled it too, and have found the same answer, but the setMaxListeners is not available in ipfs.
I am surprised also because this happens only on one computer on not on another… with the very same ipfs version (0.8.0). I will try to understand this better, and post my results here.

1 Like

It would just take a minute or two to download the entire JS implementation of IPFS (as the github zip file) just so you can search if for the word “EventEmitter”, just so you can see where and how they use it. Lots of times I can figure out workarounds or ‘root causes’ by doing that kind of thing, even thought it might even be a programming language I don’t even know sometimes! Good luck.

1 Like