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

IPFS Library has EventEmitter Memory Leak #3324

Closed
patientplatypus opened this issue Sep 4, 2018 · 1 comment
Closed

IPFS Library has EventEmitter Memory Leak #3324

patientplatypus opened this issue Sep 4, 2018 · 1 comment

Comments

@patientplatypus
Copy link

patientplatypus commented Sep 4, 2018

I'm using a library that is a websocket relay for IPFS nodes (https://github.com/libp2p/js-libp2p-websocket-star). Currently they are using socket io to transmit events, but the library often gets the following error:

(node:74215) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 disconnect listeners added. Use emitter.setMaxListeners() to increase limit

I've opened an issue here (libp2p/js-libp2p-websocket-star#58) on trying to get this fixed, and unfortunately they do not seem to know how, and neither do I.

Stack overflow (https://stackoverflow.com/questions/9768444/possible-eventemitter-memory-leak-detected) suggests using process.setMaxListeners(0), but I think that only works on websockets generally and not socket.io. I am also a little confused as to why this many event emitters (more than 10) are being created, when it appears that I am only spinning up at most 2.

If anyone has any ideas please let me know. I understand that this library is slightly orthogonal to socket.io, but it appears to be having issues that no one currently understands how to fix.

Thank you very much.

Running the rendezvous server with node --inspect gives this debug output:

Listening on: http://0.0.0.0:9090
2
warning.js:18 (node:77706) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 disconnect listeners added. Use emitter.setMaxListeners() to increase limit
writeOut	@	warning.js:18
output	@	warning.js:69
process.on	@	warning.js:100
emit	@	events.js:182
(anonymous)	@	warning.js:74
_tickCallback	@	next_tick.js:61
TickObject (async)		
init	@	inspector_async_hook.js:27
emitInitNative	@	async_hooks.js:137
emitInitScript	@	async_hooks.js:336
TickObject	@	next_tick.js:86
nextTick	@	next_tick.js:117
process.emitWarning	@	warning.js:146
_addListener	@	events.js:251
addListener	@	events.js:259
once	@	events.js:290
SIOSource	@	index.js:67
SIOPullStream.sio.createSource	@	index.js:135
SIOPullStream.sio.createProxy	@	index.js:141
peer.emit.err	@	routes.js:219
Socket.onack	@	socket.js:403
Socket.onpacket	@	socket.js:332
(anonymous)	@	client.js:214
_tickCallback	@	next_tick.js:61
TickObject (async)		
init	@	inspector_async_hook.js:27
emitInitNative	@	async_hooks.js:137
emitInitScript	@	async_hooks.js:336
TickObject	@	next_tick.js:86
nextTick	@	next_tick.js:117
Client.ondecoded	@	client.js:213
Emitter.emit	@	index.js:133
Decoder.add	@	index.js:251
Client.ondata	@	client.js:195
emit	@	events.js:182
Socket.onPacket	@	socket.js:109
emit	@	events.js:182
Transport.onPacket	@	transport.js:105
Transport.onData	@	transport.js:116
WebSocket.onData	@	websocket.js:79
emit	@	events.js:182
_receiver.onmessage	@	WebSocket.js:141
dataMessage	@	Receiver.js:389
perMessageDeflate.decompress	@	Receiver.js:349
_decompress	@	PerMessageDeflate.js:306
_inflate.flush	@	PerMessageDeflate.js:386
afterWrite	@	_stream_writable.js:480
onwrite	@	_stream_writable.js:471
afterTransform	@	_stream_transform.js:94
processCallback @ zlib.js:625
@darrachequesne
Copy link
Member

Closed due to inactivity, please reopen if needed.

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

2 participants