Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ftayyab opened this issue Aug 6, 2022 · 2 comments

Comments

@ftayyab
Copy link

ftayyab commented Aug 6, 2022

🐛 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
@ftejeria
Copy link

I removed the warning by adding in the TransportRequestOptions for the signal field a new AbortController().signal;, here an example client.search( { yourQuery }, { signal: new AbortController().signal, } Any problem attached to this workaround to remove the warning ?

@JoshMock
Copy link
Member

Closing as a duplicate of elastic/elastic-transport-js#63.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants