Skip to content

MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 abort listeners added to #1741

@ftayyab

Description

@ftayyab

🐛 Bug Report

Trying to index documents repeatedly inside a loop causing the warning.

To Reproduce

Steps to reproduce the behavior:

Paste your code here:

getFiles(basedir).then((files) => {
    const pattern = /(\d\/\d{1,}\/\d{1,})/;
    files.forEach(filepath => {
        fs.readFile(filepath, (err, data )=> {
            let zxy = filepath.match(pattern)[0];
            let base64data = Buffer.from(data).toString('base64');
            /* Possible Memory Leak with elasticsearch library */
            client.index({
                index: 'orders',
                document:{
                    zxy,
                    tile: base64data
                }
            })
        });
    });
});

Expected behavior

Although the documents are indexed, this warning still appears. The warning should not be there.

Paste the results here:

Your Environment

  • node version: 16.13.1
  • @elastic/elasticsearch latest
  • os: Windows
  • any other relevant information

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions