Skip to content

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

dylang opened this Issue Apr 5, 2012 · 5 comments

2 participants

dylang commented Apr 5, 2012

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,
    host:    '',
    ssl:     true

function send(options, cb) {

    if (! { 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:    ,
       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',;
    function(err, result){
        if (err){
            log('error', err.message || err);
        cb(err, result);

eleith commented Apr 5, 2012

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

eleith commented Apr 6, 2012

i'm not able to replicate this. i wrote a for loop that went 100 times around the html_data tests (

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!

@eleith eleith was assigned Apr 8, 2012
dylang commented Apr 8, 2012

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 commented Apr 8, 2012

@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 commented Apr 23, 2012

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 Apr 23, 2012
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.