storj-archived/kfs

EventEmitter memory leak

Closed this issue · 5 comments

 (node) warning: possible EventEmitter memory leak detected. 11 close listeners added. Use emitter.setMaxListeners() to increase limit.

Still happening at RC3:

Starting Storj node25 Port 4450
Starting Storj node26 Port 4460
Starting Storj node27 Port 4470
(node) warning: possible EventEmitter memory leak detected. 11 open listeners added. U se emitter.setMaxListeners() to increase limit.
Trace
at Sbucket.addListener (events.js:239:17)
at Sbucket.once (events.js:265:8)
at Sbucket.open (/usr/lib64/node_modules/storjshare-cli/node_modules/storj-lib/nod e_modules/kfs/lib/s-bucket.js:110:8)
at Btable._getSbucketForKey (/usr/lib64/node_modules/storjshare-cli/node_modules/s torj-lib/node_modules/kfs/lib/b-table.js:149:20)
at _getStat (/usr/lib64/node_modules/storjshare-cli/node_modules/storj-lib/node_mo dules/kfs/lib/b-table.js:195:10)
at /usr/lib64/node_modules/storjshare-cli/node_modules/storj-lib/node_modules/kfs/ node_modules/async/dist/async.js:1069:13
at replenish (/usr/lib64/node_modules/storjshare-cli/node_modules/storj-lib/node_m odules/kfs/node_modules/async/dist/async.js:884:21)
at iterateeCallback (/usr/lib64/node_modules/storjshare-cli/node_modules/storj-lib /node_modules/kfs/node_modules/async/dist/async.js:869:21)
at /usr/lib64/node_modules/storjshare-cli/node_modules/storj-lib/node_modules/kfs/ node_modules/async/dist/async.js:847:20
at /usr/lib64/node_modules/storjshare-cli/node_modules/storj-lib/node_modules/kfs/ node_modules/async/dist/async.js:1071:17
at /usr/lib64/node_modules/storjshare-cli/node_modules/storj-lib/node_modules/kfs/ lib/b-table.js:205:9
at /usr/lib64/node_modules/storjshare-cli/node_modules/storj-lib/node_modules/kfs/ lib/s-bucket.js:373:7
(node) warning: possible EventEmitter memory leak detected. 11 error listeners added. Use emitter.setMaxListeners() to increase limit.
Trace
at Sbucket.addListener (events.js:239:17)
at Sbucket.once (events.js:265:8)
at Sbucket.open (/usr/lib64/node_modules/storjshare-cli/node_modules/storj-lib/nod e_modules/kfs/lib/s-bucket.js:110:30)
at Btable._getSbucketForKey (/usr/lib64/node_modules/storjshare-cli/node_modules/s torj-lib/node_modules/kfs/lib/b-table.js:149:20)
at _getStat (/usr/lib64/node_modules/storjshare-cli/node_modules/storj-lib/node_mo dules/kfs/lib/b-table.js:195:10)

Still happening with v4.0.0 (storjshare-cli v7.0.0) :

(node) warning: possible EventEmitter memory leak detected. 11 error listeners added. Use emitter.setMaxListeners() to increase limit.
Trace
at Sbucket.addListener (events.js:239:17)
at Sbucket.once (events.js:265:8)
at Sbucket.open (/home/bigminer/storjshare-next/node_modules/storjshare-cli/node_modules/storj-lib/node_modules/kfs/lib/s-bucket.js:110:30)
at Btable._getSbucketForKey (/home/bigminer/storjshare-next/node_modules/storjshare-cli/node_modules/storj-lib/node_modules/kfs/lib/b-table.js:149:20)
at _getStat (/home/bigminer/storjshare-next/node_modules/storjshare-cli/node_modules/storj-lib/node_modules/kfs/lib/b-table.js:195:10)
at /home/bigminer/storjshare-next/node_modules/storjshare-cli/node_modules/storj-lib/node_modules/kfs/node_modules/async/dist/async.js:1069:13
at replenish (/home/bigminer/storjshare-next/node_modules/storjshare-cli/node_modules/storj-lib/node_modules/kfs/node_modules/async/dist/async.js:884:21)
at iterateeCallback (/home/bigminer/storjshare-next/node_modules/storjshare-cli/node_modules/storj-lib/node_modules/kfs/node_modules/async/dist/async.js:869:21)
at /home/bigminer/storjshare-next/node_modules/storjshare-cli/node_modules/storj-lib/node_modules/kfs/node_modules/async/dist/async.js:847:20
at /home/bigminer/storjshare-next/node_modules/storjshare-cli/node_modules/storj-lib/node_modules/kfs/node_modules/async/dist/async.js:1071:17
at /home/bigminer/storjshare-next/node_modules/storjshare-cli/node_modules/storj-lib/node_modules/kfs/lib/b-table.js:205:9
at /home/bigminer/storjshare-next/node_modules/storjshare-cli/node_modules/storj-lib/node_modules/kfs/lib/s-bucket.js:373:7

Since multiple functions can be attempting to access an sBucket via sBucket.open() this appears to stack multiple event listeners until the sBucket succeeds in opening at which point all the listeners get called and popped from the event array. So if multiple areas of the code are attempting to open the same sBucket simultaniously then I can see this.once('open', _onOpen).once('error', _onError); registering more than 10 listeners. This does not seem like a bug, but rather simply a warning that can be discarded by increasing the limit to Infinity via emitter.setMaxListeners(n).

@bookchin what do you think?

Given that each node should be dealing with CONCURRENCY levels of multiple tasks, not inifinte, I'm concerned this would just mask over a more fundemental issue.

@yuilleb yes that is most likely the case. it's not a big deal to have more than 10 listeners attached given that they are removed (they just happen to stack during a given time frame). before i say authoritatively that it's safe to increase the max listeners, i'd like to verify that the listeners are in fact being reaped properly (which given the that the tests cover this behavior, i suspect is the case).