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

[BUG] MaxListenersExceededWarning: Possible EventEmitter memory leak detected. (v10) #6763

Closed
2 tasks done
doberkofler opened this issue Sep 5, 2023 · 18 comments
Closed
2 tasks done
Assignees
Labels
Bug thing that needs fixing Priority 2 secondary priority issue regression:10.x Release 10.x

Comments

@doberkofler
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

After upgrading to npm 10, I get the following error message:

$ npm outdated
(node:53918) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
(Use `node --trace-warnings ...` to show where the warning was created)

Expected Behavior

no error

Steps To Reproduce

  1. In this environment...
  2. With this config...
  3. Run '...'
  4. See error...

Environment

  • npm: 10.0.0
  • Node.js: v20.6.0
  • OS Name: macOS 13.5.1
  • System Model Name:
  • npm config:
; "user" config from /Users/doberkofler/.npmrc

//registry.npmjs.org/:_authToken = (protected)

; "project" config from /Users/doberkofler/MyDev/ljs_app/trunk/periscope/.npmrc

engine-strict = true

; node bin location = /Users/doberkofler/.nvm/versions/node/v20.6.0/bin/node
; node version = v20.6.0
; npm local prefix = /Users/doberkofler/MyDev/ljs_app/trunk/periscope
; npm version = 10.0.0
; cwd = /Users/doberkofler/MyDev/ljs_app/trunk/periscope
; HOME = /Users/doberkofler
; Run `npm config ls -l` to show all defaults.
@doberkofler doberkofler added Bug thing that needs fixing Needs Triage needs review for next steps Release 9.x work is associated with a specific npm 9 release labels Sep 5, 2023
@rotu
Copy link
Contributor

rotu commented Sep 6, 2023

Possibly related? 7f81e96 probably not

@doberkofler doberkofler changed the title [BUG] MaxListenersExceededWarning: Possible EventEmitter memory leak detected. [BUG] MaxListenersExceededWarning: Possible EventEmitter memory leak detected. (v10) Sep 6, 2023
@lukekarrys
Copy link
Contributor

@doberkofler can you run NODE_OPTIONS=--trace-warnings npm outdated and paste the output here to show where those warnings are originating from?

@lukekarrys
Copy link
Contributor

lukekarrys commented Sep 8, 2023

I haven't been able to reproduce this yet. I've tried running npm outdated on various large install trees with many outdated packages. I also patched the TLSSocket returned from @npmcli/agent with the following code and can only ever see 1 or 2 close events being added per socket.

      const og = socket.on
      socket.on = function (...args) {
        if (args[0] === 'close') {
          console.error('close event on socket added', socket.listenerCount('close'))
        }
        return og.apply(this, args)
      }

@doberkofler A reproduction with a package.json or package-lock.json file would help a lot as well if possible.

@lukekarrys lukekarrys self-assigned this Sep 8, 2023
@lukekarrys lukekarrys added Priority 2 secondary priority issue and removed Needs Triage needs review for next steps Release 9.x work is associated with a specific npm 9 release labels Sep 8, 2023
@rotu
Copy link
Contributor

rotu commented Sep 8, 2023

I wonder if this has to do with this line in the agents.js connect() function which throws an [Error] (array with a single error) instead of throwing an Error.

https://github.com/npm/agent/blob/4b2c4d1a4d005748cd9bf5066cee29f31c56d11e/lib/agents.js#L126-L128

function once(emitter, name) {
return new Promise(function (resolve, reject) {
function errorListener(err) {
emitter.removeListener(name, resolver);
reject(err);
}
function resolver() {
if (typeof emitter.removeListener === 'function') {
emitter.removeListener('error', errorListener);
}
resolve([].slice.call(arguments));
};
eventTargetAgnosticAddListener(emitter, name, resolver, { once: true });
if (name !== 'error') {
addErrorHandlerIfEventEmitter(emitter, errorListener, { once: true });
}
});
}

@doberkofler
Copy link
Author

This is the requested output and I attached the package-lock.json file.

(node:19864) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
    at _addListener (node:events:588:17)
    at TLSSocket.addListener (node:events:606:10)
    at Readable.on (node:internal/streams/readable:904:35)
    at TLSSocket._wrapHandle (node:_tls_wrap:706:8)
    at TLSSocket.reinitializeHandle (node:_tls_wrap:715:22)
    at internalConnectMultiple (node:net:1123:30)
    at Timeout.internalConnectMultipleTimeout (node:net:1687:3)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7)
(node:19864) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
    at _addListener (node:events:588:17)
    at TLSSocket.addListener (node:events:606:10)
    at Readable.on (node:internal/streams/readable:904:35)
    at TLSSocket._wrapHandle (node:_tls_wrap:706:8)
    at TLSSocket.reinitializeHandle (node:_tls_wrap:715:22)
    at internalConnectMultiple (node:net:1123:30)
    at Timeout.internalConnectMultipleTimeout (node:net:1687:3)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7)
(node:19864) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
    at _addListener (node:events:588:17)
    at TLSSocket.addListener (node:events:606:10)
    at Readable.on (node:internal/streams/readable:904:35)
    at TLSSocket._wrapHandle (node:_tls_wrap:706:8)
    at TLSSocket.reinitializeHandle (node:_tls_wrap:715:22)
    at internalConnectMultiple (node:net:1123:30)
    at Timeout.internalConnectMultipleTimeout (node:net:1687:3)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7)
(node:19864) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
    at _addListener (node:events:588:17)
    at TLSSocket.addListener (node:events:606:10)
    at Readable.on (node:internal/streams/readable:904:35)
    at TLSSocket._wrapHandle (node:_tls_wrap:706:8)
    at TLSSocket.reinitializeHandle (node:_tls_wrap:715:22)
    at internalConnectMultiple (node:net:1123:30)
    at Timeout.internalConnectMultipleTimeout (node:net:1687:3)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7)
(node:19864) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
    at _addListener (node:events:588:17)
    at TLSSocket.addListener (node:events:606:10)
    at Readable.on (node:internal/streams/readable:904:35)
    at TLSSocket._wrapHandle (node:_tls_wrap:706:8)
    at TLSSocket.reinitializeHandle (node:_tls_wrap:715:22)
    at internalConnectMultiple (node:net:1123:30)
    at Timeout.internalConnectMultipleTimeout (node:net:1687:3)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7)
(node:19864) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
    at _addListener (node:events:588:17)
    at TLSSocket.addListener (node:events:606:10)
    at Readable.on (node:internal/streams/readable:904:35)
    at TLSSocket._wrapHandle (node:_tls_wrap:706:8)
    at TLSSocket.reinitializeHandle (node:_tls_wrap:715:22)
    at internalConnectMultiple (node:net:1123:30)
    at Timeout.internalConnectMultipleTimeout (node:net:1687:3)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7)
(node:19864) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
    at _addListener (node:events:588:17)
    at TLSSocket.addListener (node:events:606:10)
    at Readable.on (node:internal/streams/readable:904:35)
    at TLSSocket._wrapHandle (node:_tls_wrap:706:8)
    at TLSSocket.reinitializeHandle (node:_tls_wrap:715:22)
    at internalConnectMultiple (node:net:1123:30)
    at Timeout.internalConnectMultipleTimeout (node:net:1687:3)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7)
(node:19864) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
    at _addListener (node:events:588:17)
    at TLSSocket.addListener (node:events:606:10)
    at Readable.on (node:internal/streams/readable:904:35)
    at TLSSocket._wrapHandle (node:_tls_wrap:706:8)
    at TLSSocket.reinitializeHandle (node:_tls_wrap:715:22)
    at internalConnectMultiple (node:net:1123:30)
    at Timeout.internalConnectMultipleTimeout (node:net:1687:3)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7)
(node:19864) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
    at _addListener (node:events:588:17)
    at TLSSocket.addListener (node:events:606:10)
    at Readable.on (node:internal/streams/readable:904:35)
    at TLSSocket._wrapHandle (node:_tls_wrap:706:8)
    at TLSSocket.reinitializeHandle (node:_tls_wrap:715:22)
    at internalConnectMultiple (node:net:1123:30)
    at Timeout.internalConnectMultipleTimeout (node:net:1687:3)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7)
(node:19864) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
    at _addListener (node:events:588:17)
    at TLSSocket.addListener (node:events:606:10)
    at Readable.on (node:internal/streams/readable:904:35)
    at TLSSocket._wrapHandle (node:_tls_wrap:706:8)
    at TLSSocket.reinitializeHandle (node:_tls_wrap:715:22)
    at internalConnectMultiple (node:net:1123:30)
    at Timeout.internalConnectMultipleTimeout (node:net:1687:3)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7)
(node:19864) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
    at _addListener (node:events:588:17)
    at TLSSocket.addListener (node:events:606:10)
    at Readable.on (node:internal/streams/readable:904:35)
    at TLSSocket._wrapHandle (node:_tls_wrap:706:8)
    at TLSSocket.reinitializeHandle (node:_tls_wrap:715:22)
    at internalConnectMultiple (node:net:1123:30)
    at Timeout.internalConnectMultipleTimeout (node:net:1687:3)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7)
(node:19864) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
    at _addListener (node:events:588:17)
    at TLSSocket.addListener (node:events:606:10)
    at Readable.on (node:internal/streams/readable:904:35)
    at TLSSocket._wrapHandle (node:_tls_wrap:706:8)
    at TLSSocket.reinitializeHandle (node:_tls_wrap:715:22)
    at internalConnectMultiple (node:net:1123:30)
    at Timeout.internalConnectMultipleTimeout (node:net:1687:3)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7)
(node:19864) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
    at _addListener (node:events:588:17)
    at TLSSocket.addListener (node:events:606:10)
    at Readable.on (node:internal/streams/readable:904:35)
    at TLSSocket._wrapHandle (node:_tls_wrap:706:8)
    at TLSSocket.reinitializeHandle (node:_tls_wrap:715:22)
    at internalConnectMultiple (node:net:1123:30)
    at Timeout.internalConnectMultipleTimeout (node:net:1687:3)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7)
(node:19864) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
    at _addListener (node:events:588:17)
    at TLSSocket.addListener (node:events:606:10)
    at Readable.on (node:internal/streams/readable:904:35)
    at TLSSocket._wrapHandle (node:_tls_wrap:706:8)
    at TLSSocket.reinitializeHandle (node:_tls_wrap:715:22)
    at internalConnectMultiple (node:net:1123:30)
    at Timeout.internalConnectMultipleTimeout (node:net:1687:3)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7)
(node:19864) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
    at _addListener (node:events:588:17)
    at TLSSocket.addListener (node:events:606:10)
    at Readable.on (node:internal/streams/readable:904:35)
    at TLSSocket._wrapHandle (node:_tls_wrap:706:8)
    at TLSSocket.reinitializeHandle (node:_tls_wrap:715:22)
    at internalConnectMultiple (node:net:1123:30)
    at Timeout.internalConnectMultipleTimeout (node:net:1687:3)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7)
(node:19864) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
    at _addListener (node:events:588:17)
    at TLSSocket.addListener (node:events:606:10)
    at Readable.on (node:internal/streams/readable:904:35)
    at TLSSocket._wrapHandle (node:_tls_wrap:706:8)
    at TLSSocket.reinitializeHandle (node:_tls_wrap:715:22)
    at internalConnectMultiple (node:net:1123:30)
    at Timeout.internalConnectMultipleTimeout (node:net:1687:3)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7)
(node:19864) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
    at _addListener (node:events:588:17)
    at TLSSocket.addListener (node:events:606:10)
    at Readable.on (node:internal/streams/readable:904:35)
    at TLSSocket._wrapHandle (node:_tls_wrap:706:8)
    at TLSSocket.reinitializeHandle (node:_tls_wrap:715:22)
    at internalConnectMultiple (node:net:1123:30)
    at Timeout.internalConnectMultipleTimeout (node:net:1687:3)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7)
(node:19864) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
    at _addListener (node:events:588:17)
    at TLSSocket.addListener (node:events:606:10)
    at Readable.on (node:internal/streams/readable:904:35)
    at TLSSocket._wrapHandle (node:_tls_wrap:706:8)
    at TLSSocket.reinitializeHandle (node:_tls_wrap:715:22)
    at internalConnectMultiple (node:net:1123:30)
    at Timeout.internalConnectMultipleTimeout (node:net:1687:3)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7)
(node:19864) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
    at _addListener (node:events:588:17)
    at TLSSocket.addListener (node:events:606:10)
    at Readable.on (node:internal/streams/readable:904:35)
    at TLSSocket._wrapHandle (node:_tls_wrap:706:8)
    at TLSSocket.reinitializeHandle (node:_tls_wrap:715:22)
    at internalConnectMultiple (node:net:1123:30)
    at Timeout.internalConnectMultipleTimeout (node:net:1687:3)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7)
(node:19864) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
    at _addListener (node:events:588:17)
    at TLSSocket.addListener (node:events:606:10)
    at Readable.on (node:internal/streams/readable:904:35)
    at TLSSocket._wrapHandle (node:_tls_wrap:706:8)
    at TLSSocket.reinitializeHandle (node:_tls_wrap:715:22)
    at internalConnectMultiple (node:net:1123:30)
    at Timeout.internalConnectMultipleTimeout (node:net:1687:3)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7)
(node:19864) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
    at _addListener (node:events:588:17)
    at TLSSocket.addListener (node:events:606:10)
    at Readable.on (node:internal/streams/readable:904:35)
    at TLSSocket._wrapHandle (node:_tls_wrap:706:8)
    at TLSSocket.reinitializeHandle (node:_tls_wrap:715:22)
    at internalConnectMultiple (node:net:1123:30)
    at Timeout.internalConnectMultipleTimeout (node:net:1687:3)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7)
(node:19864) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
    at _addListener (node:events:588:17)
    at TLSSocket.addListener (node:events:606:10)
    at Readable.on (node:internal/streams/readable:904:35)
    at TLSSocket._wrapHandle (node:_tls_wrap:706:8)
    at TLSSocket.reinitializeHandle (node:_tls_wrap:715:22)
    at internalConnectMultiple (node:net:1123:30)
    at Timeout.internalConnectMultipleTimeout (node:net:1687:3)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7)
(node:19864) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
    at _addListener (node:events:588:17)
    at TLSSocket.addListener (node:events:606:10)
    at Readable.on (node:internal/streams/readable:904:35)
    at TLSSocket._wrapHandle (node:_tls_wrap:706:8)
    at TLSSocket.reinitializeHandle (node:_tls_wrap:715:22)
    at internalConnectMultiple (node:net:1123:30)
    at Timeout.internalConnectMultipleTimeout (node:net:1687:3)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7)
(node:19864) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
    at _addListener (node:events:588:17)
    at TLSSocket.addListener (node:events:606:10)
    at Readable.on (node:internal/streams/readable:904:35)
    at TLSSocket._wrapHandle (node:_tls_wrap:706:8)
    at TLSSocket.reinitializeHandle (node:_tls_wrap:715:22)
    at internalConnectMultiple (node:net:1123:30)
    at Timeout.internalConnectMultipleTimeout (node:net:1687:3)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7)
(node:19864) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
    at _addListener (node:events:588:17)
    at TLSSocket.addListener (node:events:606:10)
    at Readable.on (node:internal/streams/readable:904:35)
    at TLSSocket._wrapHandle (node:_tls_wrap:706:8)
    at TLSSocket.reinitializeHandle (node:_tls_wrap:715:22)
    at internalConnectMultiple (node:net:1123:30)
    at Timeout.internalConnectMultipleTimeout (node:net:1687:3)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7)
(node:19864) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
    at _addListener (node:events:588:17)
    at TLSSocket.addListener (node:events:606:10)
    at Readable.on (node:internal/streams/readable:904:35)
    at TLSSocket._wrapHandle (node:_tls_wrap:706:8)
    at TLSSocket.reinitializeHandle (node:_tls_wrap:715:22)
    at internalConnectMultiple (node:net:1123:30)
    at Timeout.internalConnectMultipleTimeout (node:net:1687:3)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7)
(node:19864) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
    at _addListener (node:events:588:17)
    at TLSSocket.addListener (node:events:606:10)
    at Readable.on (node:internal/streams/readable:904:35)
    at TLSSocket._wrapHandle (node:_tls_wrap:706:8)
    at TLSSocket.reinitializeHandle (node:_tls_wrap:715:22)
    at internalConnectMultiple (node:net:1123:30)
    at Timeout.internalConnectMultipleTimeout (node:net:1687:3)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7)
(node:19864) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
    at _addListener (node:events:588:17)
    at TLSSocket.addListener (node:events:606:10)
    at Readable.on (node:internal/streams/readable:904:35)
    at TLSSocket._wrapHandle (node:_tls_wrap:706:8)
    at TLSSocket.reinitializeHandle (node:_tls_wrap:715:22)
    at internalConnectMultiple (node:net:1123:30)
    at Timeout.internalConnectMultipleTimeout (node:net:1687:3)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7)
(node:19864) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
    at _addListener (node:events:588:17)
    at TLSSocket.addListener (node:events:606:10)
    at Readable.on (node:internal/streams/readable:904:35)
    at TLSSocket._wrapHandle (node:_tls_wrap:706:8)
    at TLSSocket.reinitializeHandle (node:_tls_wrap:715:22)
    at internalConnectMultiple (node:net:1123:30)
    at Timeout.internalConnectMultipleTimeout (node:net:1687:3)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7)
(node:19864) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
    at _addListener (node:events:588:17)
    at TLSSocket.addListener (node:events:606:10)
    at Readable.on (node:internal/streams/readable:904:35)
    at TLSSocket._wrapHandle (node:_tls_wrap:706:8)
    at TLSSocket.reinitializeHandle (node:_tls_wrap:715:22)
    at internalConnectMultiple (node:net:1123:30)
    at Timeout.internalConnectMultipleTimeout (node:net:1687:3)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7)
(node:19864) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
    at _addListener (node:events:588:17)
    at TLSSocket.addListener (node:events:606:10)
    at Readable.on (node:internal/streams/readable:904:35)
    at TLSSocket._wrapHandle (node:_tls_wrap:706:8)
    at TLSSocket.reinitializeHandle (node:_tls_wrap:715:22)
    at internalConnectMultiple (node:net:1123:30)
    at Timeout.internalConnectMultipleTimeout (node:net:1687:3)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7)
(node:19864) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
    at _addListener (node:events:588:17)
    at TLSSocket.addListener (node:events:606:10)
    at Readable.on (node:internal/streams/readable:904:35)
    at TLSSocket._wrapHandle (node:_tls_wrap:706:8)
    at TLSSocket.reinitializeHandle (node:_tls_wrap:715:22)
    at internalConnectMultiple (node:net:1123:30)
    at Timeout.internalConnectMultipleTimeout (node:net:1687:3)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7)
(node:19864) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
    at _addListener (node:events:588:17)
    at TLSSocket.addListener (node:events:606:10)
    at Readable.on (node:internal/streams/readable:904:35)
    at TLSSocket._wrapHandle (node:_tls_wrap:706:8)
    at TLSSocket.reinitializeHandle (node:_tls_wrap:715:22)
    at internalConnectMultiple (node:net:1123:30)
    at Timeout.internalConnectMultipleTimeout (node:net:1687:3)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7)
(node:19864) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
    at _addListener (node:events:588:17)
    at TLSSocket.addListener (node:events:606:10)
    at Readable.on (node:internal/streams/readable:904:35)
    at TLSSocket._wrapHandle (node:_tls_wrap:706:8)
    at TLSSocket.reinitializeHandle (node:_tls_wrap:715:22)
    at internalConnectMultiple (node:net:1123:30)
    at Timeout.internalConnectMultipleTimeout (node:net:1687:3)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7)
(node:19864) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
    at _addListener (node:events:588:17)
    at TLSSocket.addListener (node:events:606:10)
    at Readable.on (node:internal/streams/readable:904:35)
    at TLSSocket._wrapHandle (node:_tls_wrap:706:8)
    at TLSSocket.reinitializeHandle (node:_tls_wrap:715:22)
    at internalConnectMultiple (node:net:1123:30)
    at Timeout.internalConnectMultipleTimeout (node:net:1687:3)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7)
(node:19864) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
    at _addListener (node:events:588:17)
    at TLSSocket.addListener (node:events:606:10)
    at Readable.on (node:internal/streams/readable:904:35)
    at TLSSocket._wrapHandle (node:_tls_wrap:706:8)
    at TLSSocket.reinitializeHandle (node:_tls_wrap:715:22)
    at internalConnectMultiple (node:net:1123:30)
    at Timeout.internalConnectMultipleTimeout (node:net:1687:3)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7)
(node:19864) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
    at _addListener (node:events:588:17)
    at TLSSocket.addListener (node:events:606:10)
    at Readable.on (node:internal/streams/readable:904:35)
    at TLSSocket._wrapHandle (node:_tls_wrap:706:8)
    at TLSSocket.reinitializeHandle (node:_tls_wrap:715:22)
    at internalConnectMultiple (node:net:1123:30)
    at Timeout.internalConnectMultipleTimeout (node:net:1687:3)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7)
(node:19864) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
    at _addListener (node:events:588:17)
    at TLSSocket.addListener (node:events:606:10)
    at Readable.on (node:internal/streams/readable:904:35)
    at TLSSocket._wrapHandle (node:_tls_wrap:706:8)
    at TLSSocket.reinitializeHandle (node:_tls_wrap:715:22)
    at internalConnectMultiple (node:net:1123:30)
    at Timeout.internalConnectMultipleTimeout (node:net:1687:3)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7)
(node:19864) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
    at _addListener (node:events:588:17)
    at TLSSocket.addListener (node:events:606:10)
    at Readable.on (node:internal/streams/readable:904:35)
    at TLSSocket._wrapHandle (node:_tls_wrap:706:8)
    at TLSSocket.reinitializeHandle (node:_tls_wrap:715:22)
    at internalConnectMultiple (node:net:1123:30)
    at Timeout.internalConnectMultipleTimeout (node:net:1687:3)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7)
(node:19864) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
    at _addListener (node:events:588:17)
    at TLSSocket.addListener (node:events:606:10)
    at Readable.on (node:internal/streams/readable:904:35)
    at TLSSocket._wrapHandle (node:_tls_wrap:706:8)
    at TLSSocket.reinitializeHandle (node:_tls_wrap:715:22)
    at internalConnectMultiple (node:net:1123:30)
    at Timeout.internalConnectMultipleTimeout (node:net:1687:3)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7)
(node:19864) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
    at _addListener (node:events:588:17)
    at TLSSocket.addListener (node:events:606:10)
    at Readable.on (node:internal/streams/readable:904:35)
    at TLSSocket._wrapHandle (node:_tls_wrap:706:8)
    at TLSSocket.reinitializeHandle (node:_tls_wrap:715:22)
    at internalConnectMultiple (node:net:1123:30)
    at Timeout.internalConnectMultipleTimeout (node:net:1687:3)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7)
(node:19864) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
    at _addListener (node:events:588:17)
    at TLSSocket.addListener (node:events:606:10)
    at Readable.on (node:internal/streams/readable:904:35)
    at TLSSocket._wrapHandle (node:_tls_wrap:706:8)
    at TLSSocket.reinitializeHandle (node:_tls_wrap:715:22)
    at internalConnectMultiple (node:net:1123:30)
    at Timeout.internalConnectMultipleTimeout (node:net:1687:3)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7)
(node:19864) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
    at _addListener (node:events:588:17)
    at TLSSocket.addListener (node:events:606:10)
    at Readable.on (node:internal/streams/readable:904:35)
    at TLSSocket._wrapHandle (node:_tls_wrap:706:8)
    at TLSSocket.reinitializeHandle (node:_tls_wrap:715:22)
    at internalConnectMultiple (node:net:1123:30)
    at Timeout.internalConnectMultipleTimeout (node:net:1687:3)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7)
Package         Current  Wanted        Latest  Location                     Depended by
@types/select2    3.5.6   3.5.6        4.0.58  node_modules/@types/select2  periscope
chalk             4.1.2   4.1.2         5.3.0  node_modules/chalk           periscope
dropzone          5.9.3   5.9.3  6.0.0-beta.2  node_modules/dropzone        periscope
select2           3.5.1   3.5.1    4.1.0-rc.0  node_modules/select2         periscope

package-lock.json.zip

@rotu
Copy link
Contributor

rotu commented Sep 8, 2023

@lukekarrys
Copy link
Contributor

thank you @doberkofler for the reproduction. I was able to find that this only happens in Node 20.4.0 and above, and goes away if the Node flag --no-network-family-autoselection is used.

So a potential workaround is to use NODE_OPTIONS=--no-network-family-autoselection when calling npm.

I also created a failing test case in https://github.com/npm/cli/pull/6781/files to document the current behavior. I'm sure this is due to the new @npmcli/agent but unsure if the fix will end up being there or possibly in Node. This PR in Node points to some other libraries having issues with network family autoselection but only in earlier releases: nodejs/node#48464

@rotu
Copy link
Contributor

rotu commented Oct 4, 2023

So a potential workaround is to use NODE_OPTIONS=--no-network-family-autoselection when calling npm.

BTW, this seems to cause trouble with VSCode:

➜  ~ npm config edit
/Applications/Visual Studio Code.app/Contents/MacOS/Electron: --no-network-family-autoselection is not allowed in NODE_OPTIONS
npm ERR! editor process exited with code: 9

@pimterry
Copy link

Can't be 100% sure, but I think I've found a small bug in Node that could the underlying cause of this (nodejs/node#50136) - once that's resolved this might go away 😄. Thanks to @lukekarrys for the pointers towards autoSelectFamily being the trigger here!

@soulchild
Copy link

This makes it impossible for us to make the switch to Node 20 because all projects are failing our Gitlab CI build pipeline.

I tried the suggested --no-network-family-autoselection workaround which seems to make the MaxListenersExceededWarning warnings disappear, but then the npm install command immediately fails with an ECONNREFUSED error.

We're behind a proxy and my experience has been that 90% of ECONNREFUSED errors are due to abysmal proxy support in Node.js and third-party libraries.

@soulchild
Copy link

I just found out that the current Node LTS 20.9.0 ships with npm v10.1.0 which is known to ignore proxy environment variables. So I'm probably seeing two distinct problems here.

@lukekarrys
Copy link
Contributor

I believe this is now fixed due to the linked Node bug above being fixed.

@lukewealth
Copy link

I believe this is now fixed due to the linked Node bug above being fixed.

sorry please i am confused. How did you fix it?

@mklueh
Copy link

mklueh commented Nov 29, 2023

I'm facing the same with Yarn 4.0.2

@soulchild
Copy link

I can confirm that this error is gone with the latest Node 20.10.0. Also, proxies are working again with the included npm 10.2.3.

@chuksjoe
Copy link

chuksjoe commented Feb 8, 2024

I upgraded my node version to v20.11.0 and the issue disappeared.

@Manraj689
Copy link

Upgraded the node version to 20.11.1, but still persists

alcpereira added a commit to alcpereira/100hunters that referenced this issue Mar 18, 2024
Bumping to 20.11.0 due to a bug with event emitter on npm install
See: npm/cli#6763 (comment)
@CORTEZpedr
Copy link

I encountered the warning with the same message. After upgrading to Node.js version 20.11.0, the warning disappeared:

 ○ Compiling / ...
(node:25775) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
    at _addListener (node:events:588:17)
    at TLSSocket.addListener (node:events:606:10)
    at Readable.on (node:internal/streams/readable:904:35)
    at TLSSocket._wrapHandle (node:_tls_wrap:674:8)
    at TLSSocket.reinitializeHandle (node:_tls_wrap:683:22)
    at internalConnectMultiple (node:net:1123:30)
    at internalConnectMultiple (node:net:1177:5)
    at Timeout.internalConnectMultipleTimeout (node:net:1687:3)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7)

.....

✓ Compiled / in 8.1s (2406 modules)

$ node --version
v20.5.0
$ nvm install 20.11.0
Downloading and installing node v20.11.0...
Downloading https://nodejs.org/dist/v20.11.0/node-v20.11.0-linux-x64.tar.xz...
############################################################################# 100.0%
Computing checksum with sha256sum
Checksums matched!
Now using node v20.11.0 (npm v10.2.4)

After this, the warning no longer appeared.

○ Compiling / ...
 ✓ Compiled / in 2.9s (2314 modules)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Priority 2 secondary priority issue regression:10.x Release 10.x
Projects
None yet
Development

No branches or pull requests