| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 74685f1 commit 58a65d6
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,7 +2,7 @@ | |||
| 2 | 2 | const common = require('../common.js'); | |
| 3 | 3 | const events = require('events'); | |
| 4 | 4 | ||
| 5 | - const bench = common.createBenchmark(main, { n: [25e4] }); | ||
| 5 | + const bench = common.createBenchmark(main, { n: [1e6] }); | ||
| 6 | 6 | ||
| 7 | 7 | function main({ n }) { | |
| 8 | 8 | const ee = new events.EventEmitter(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -235,22 +235,20 @@ function _addListener(target, type, listener, prepend) { | |||
| 235 | 235 | } | |
| 236 | 236 | ||
| 237 | 237 | // Check for listener leak | |
| 238 | - if (!existing.warned) { | ||
| 239 | - m = $getMaxListeners(target); | ||
| 240 | - if (m && m > 0 && existing.length > m) { | ||
| 241 | - existing.warned = true; | ||
| 242 | - // No error code for this since it is a Warning | ||
| 243 | - // eslint-disable-next-line no-restricted-syntax | ||
| 244 | - const w = new Error('Possible EventEmitter memory leak detected. ' + | ||
| 245 | - `${existing.length} ${String(type)} listeners ` + | ||
| 246 | - 'added. Use emitter.setMaxListeners() to ' + | ||
| 247 | - 'increase limit'); | ||
| 248 | - w.name = 'MaxListenersExceededWarning'; | ||
| 249 | - w.emitter = target; | ||
| 250 | - w.type = type; | ||
| 251 | - w.count = existing.length; | ||
| 252 | - process.emitWarning(w); | ||
| 253 | - } | ||
| 238 | + m = $getMaxListeners(target); | ||
| 239 | + if (m > 0 && existing.length > m && !existing.warned) { | ||
| 240 | + existing.warned = true; | ||
| 241 | + // No error code for this since it is a Warning | ||
| 242 | + // eslint-disable-next-line no-restricted-syntax | ||
| 243 | + const w = new Error('Possible EventEmitter memory leak detected. ' + | ||
| 244 | + `${existing.length} ${String(type)} listeners ` + | ||
| 245 | + 'added. Use emitter.setMaxListeners() to ' + | ||
| 246 | + 'increase limit'); | ||
| 247 | + w.name = 'MaxListenersExceededWarning'; | ||
| 248 | + w.emitter = target; | ||
| 249 | + w.type = type; | ||
| 250 | + w.count = existing.length; | ||
| 251 | + process.emitWarning(w); | ||
| 254 | 252 | } | |
| 255 | 253 | } | |
| 256 | 254 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments