Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

FATAL ERROR: JS Allocation failed - process out of memory #27

Closed
dylang opened this Issue · 5 comments

2 participants

Dylan Greene eleith
Dylan Greene

Runs fine on my mac, but on our Linux server after sending a bunch of emails successfully (maybe 6-10) i get FATAL ERROR: JS Allocation failed - process out of memory killing Node. The emails are a couple lines of text and html, each is sent to just one person.

var Server  = EmailJs.server.connect({
    user:    process.env.CATAPULT_EMAIL,
    password:process.env.CATAPULT_EMAIL_PASSWORD,
    host:    'smtp.gmail.com',
    ssl:     true
});

function send(options, cb) {

    if (!options.to) { log('to required'); return cb();}
    if (!options.subject) { log('subject required'); return cb();}
    if (!options.text) { log('message required'); return cb();}
    if (!process.env.CATAPULT_EMAIL) { log('catapult email required'); return cb();}
    if (!process.env.CATAPULT_EMAIL_PASSWORD) { log('catapult password required'); return cb();}

   var headers = {
       to:              options.to,
       from:            options.from,
       subject:         options.subject,
       text:            options.text,
       authentication: false
   };

    var Message = EmailJs.message.create(headers);

    if (options.html) {
        Message.attach({data: options.html, alternative:true});
    }
    log('sending email to', options.to);
    Server.send(Message,
    function(err, result){
        if (err){
            log('error', err.message || err);
        }
        //process.exit();
        cb(err, result);
    });

}
eleith
Owner

woah. ok, i'll look into this tonight. btw, loving doodle or die!

eleith
Owner

i'm not able to replicate this. i wrote a for loop that went 100 times around the html_data tests (https://github.com/eleith/emailjs/blob/master/test/tests.js#L19)

and it sent off 100 emails without hitting any errors.

please let me know if this test doesn't properly represent the actions you are taking. from your code above, it seems to match well.

i'm happy to start looking for memory leaks, but it would be good to know more specifics on what you're sending and if you can replicate the environment in isolation of your other code.

keep me posted!

Dylan Greene

Glad you like Doodle or Die! Thanks for looking into this so quickly. The same email work fine on my local mac - on the linux box it randomly dies after 4 or so messages. I wonder if it's something with the linux box. This is for a side project at my real job (Opower) not Doodle or Die so it's not a high priority.

eleith
Owner

@dylang how are you getting the HTML into memory? for the tests i used, i was reading them through fs.readFileSync, so i only ever had one full file in memory at a time.

otherwise, off the top of my head, i'm not sure where-else enough memory is consumed to trigger those errors. i run emailjs on a couple of linux servers on production machines, and i haven't come across this yet, so it must be happening either in some part of the code that i don't use often myself (ex: attaching streams) or there might be something unique in your environment that is triggering it.

also, i think i'm running it with node 0.6.7 (latest is at 0.6.14).

keep me posted if you are able to narrow down what causes the error, and i'll happily do my best to solve this for you.

eleith
Owner

going to close this and make note that this issue is unresolved.

without a test case to reproduce this error consistently it will be very hard to pinpoint the cause of the error.

feel free to re-open if you find out more information.

eleith eleith closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.