Calling send() in loop with 11+ iterations causes memory leak warning
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 385
- Forks
- 60
- PR merge metrics
- No merged PRs in 30d
Description
Getting the following when I fire off emails inside a loop with 11+ iterations (i.e., 10 or fewer iterations doesn't generate this warning):
c$ node mailer-test.js
(node) warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit.
Trace:
at SMTPClient.<anonymous> (events.js:133:17)
at SMTPClientPool.send (/Users/c/dev/mailer-test/node_modules/mailer/lib/node_mailer.js:72:10)
at dispatchMail (/Users/c/dev/mailer-test/node_modules/mailer/lib/node_mailer.js:112:12)
at Object.node_mail [as send] (/Users/c/dev/mailer-test/node_modules/mailer/lib/node_mailer.js:159:5)
at Object.<anonymous> (/Users/c/dev/mailer-test/mailer-test.js:5:10)
at Module._compile (module.js:425:26)
at Object..js (module.js:443:10)
at Module.load (module.js:344:31)
at Function._load (module.js:303:12)
at Array.0 (module.js:463:10)
To be clear, everything works (emails are sent)--just reporting the memory leak warning. Maybe a false positive?
Tested with mailer 0.6.7 and node 0.5.7 (darwin) / 0.6.3 (win32) using the following:
var mailer = require('mailer');
for(var i = 0; i < 11; i++) { // Change 11 to 10 and warnings no longer appear
mailer.send({
to: 'Some Body <someone@somewhere.com>',
from : 'Me <me@somewhereelse.com>',
subject: 'Test '+i,
body: 'Blah',
host : "xxx",
port : "465",
ssl: true,
authentication : "login",
username : "xxx",
password : "yyy"
},
function(err, result){
if(err){ console.log(err); }
}
);
}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the warning with the provided mailer-test.js loop using 11 sends, then inspect lib/node_mailer.js at SMTPClientPool.send (line 72), dispatchMail (line 112), and node_mail (line 159). Trace how listeners are registered and removed, and verify that repeated sends complete without the EventEmitter warning while preserving the existing callbacks and email delivery.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100