ipfs / js-ipfs

IPFS implementation in JavaScript
https://js.ipfs.tech
Other
7.44k stars 1.25k forks source link

[Again] MaxListenersExceededWarning: Possible EventTarget memory leak detected. 11 abort listeners added to #4321

Closed chiro-hiro closed 1 year ago

chiro-hiro commented 1 year ago

Version: { version: '0.18.0', commit: '', repo: '12', 'ipfs-core': '0.18.0', 'interface-ipfs-core': '^0.158.0' }

Node.js v16.18.1

Severity:

Medium

Description:

I use, ipfs.dag.get() and ipfs.dag.put() to update my DAG. Got this error whenever I leave it run for around 1 min.

(node:11250) MaxListenersExceededWarning: Possible EventTarget memory leak detected. 11 abort listeners added to [AbortSignal]. Use events.setMaxListeners() to increase limit
    at AbortSignal.[kNewListener] (node:internal/event_target:519:17)
    at AbortSignal.[kNewListener] (node:internal/abort_controller:180:24)
    at AbortSignal.addEventListener (node:internal/event_target:628:23)
    at abortable (file:///Users/chiro/GitHub/zkDatabase/zkdb/node_modules/abortable-iterator/dist/src/index.js:13:16)
    at abortable.next (<anonymous>)
    at file:///Users/chiro/GitHub/zkDatabase/zkdb/node_modules/it-handshake/dist/src/index.js:14:9
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async abortable (file:///Users/chiro/GitHub/zkDatabase/zkdb/node_modules/abortable-iterator/dist/src/index.js:28:26)
    at async Object.sink (file:///Users/chiro/GitHub/zkDatabase/zkdb/node_modules/@libp2p/mplex/dist/src/stream.js:127:32)

Steps to reproduce the error:


  public async put<T>(collection: string, document: T, option?: PutOptions) {
    await this.loadCollection(collection);
    let documentDigest = await this.poseidonHash(document);

    const result = await this.nodeInstance.dag.put(document, {
      pin: true,
      ...option,
    });
    const cid = result.toString();
    this.collections[collection][documentDigest] = cid;

    await this.nodeInstance.files.write(
      this.getCollectionPath(collection),
      JSON.stringify(this.collections[collection])
    );

    return {
      CID: cid,
      documentID: documentDigest,
      timestamp: Date.now(),
      database: this.config.database,
      collection,
      document,
    };
  }
welcome[bot] commented 1 year ago

Thank you for submitting your first issue to this repository! A maintainer will be here shortly to triage and review. In the meantime, please double-check that you have provided all the necessary information to make this process easy! Any information that can help save additional round trips is useful! We currently aim to give initial feedback within two business days. If this does not happen, feel free to leave a comment. Please keep an eye on how this issue will be labeled, as labels give an overview of priorities, assignments and additional actions requested by the maintainers:

Finally, remember to use https://discuss.ipfs.io if you just need general support.

achingbrain commented 1 year ago

js-IPFS is in the process of being deprecated, the replacement is Helia - please see the State of IPFS in JS post for a bit of background and the migration guide for how to port your app over.

Please can you try with Helia, all of these warnings should have been squished in the latest libp2p releases - please open an issue if not.