elastic / elasticsearch-js

Official Elasticsearch client library for Node.js
https://ela.st/js-client
Apache License 2.0
25 stars 728 forks source link

Abort signal - Possible EventEmitter memory leak detected. 11 abort listeners added to [EventEmitter]. Use emitter.setMaxListeners() to increase limit #1716

Closed ronag closed 1 year ago

ronag commented 2 years ago

When using abort signal with the esc client I get the following:

Possible EventEmitter memory leak detected. 11 abort listeners added to [EventEmitter]. Use emitter.setMaxListeners() to increase limit

Is esc or maybe undici missing to release the abort signal handler?

ronag commented 2 years ago

I'm trying to get more info.

ronag commented 2 years ago

Might be related to pipelining.

netlob commented 2 years ago

Getting this warning too 👍

ronag commented 2 years ago

So this has nothing to do with abort signal. It has to do with number of concurrent requests without signals.

https://github.com/elastic/elastic-transport-js/blob/main/src/connection/UndiciConnection.ts#L126

Every request without signal adds an abort listener to the connection. This is not optimal...

Czpla commented 2 years ago

Estou recebendo o mesmo aviso aqui também.

NĂŁo sei se essa issue pode ajudar em algo: https://github.com/node-fetch/node-fetch/issues/1295

slavaGanzin commented 1 year ago
(node:24750) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 abort listeners added to [EventEmitter]. Use emitter.setMaxListeners() to increase limit
MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 abort listeners added to [EventEmitter]. Use emitter.setMaxListeners() to increase limit
    at _addListener (node:events:585:17)
    at EventEmitter.addListener (node:events:603:10)
    at addSignal (node_modules/undici/lib/api/abort-signal.js:35:19)
    at new RequestHandler (node_modules/undici/lib/api/api-request.js:68:5)
    at Pool.request (node_modules/undici/lib/api/api-request.js:170:25)
    at node_modules/undici/lib/api/api-request.js:163:15
    at new Promise (<anonymous>)
    at Pool.request (/node_modules/undici/lib/api/api-request.js:162:12)
    at Connection.request (node_modules/@elastic/transport/lib/connection/UndiciConnection.js:143:41)
    at SniffingTransport.request (node_modules/@elastic/transport/lib/Transport.js:412:75)
    at Client.GetApi [as get] (node_modules/@elastic/elasticsearch/lib/api/api/get.js:36:33)
    // my code
{
  emitter: EventEmitter {
    _events: [Object: null prototype] { abort: [Array] },
    _eventsCount: 1,
    _maxListeners: undefined,
    [Symbol(kCapture)]: false
  },
  type: 'abort',
  count: 11
}
JoshMock commented 1 year ago

This was fixed and released in v8.8.1. See https://github.com/elastic/elastic-transport-js/issues/63.

daveyarwood commented 6 months ago

I'm running into this currently, using @elastic/elasticsearch 8.13.1 and @elastic/transport 8.5.1. It seems the issue is unresolved.

See https://github.com/nodejs/undici/issues/3131

JoshMock commented 6 months ago

Thanks for linking to that issue @daveyarwood. I'll take another look and continue to keep track over on https://github.com/elastic/elastic-transport-js/issues/63.