0

My script is failing when attempting to load the template, with the following error:

FATAL ERROR: JS Allocation failed - process out of memory exited with code 5

The code that I'm calling looks like this:

emailTemplates(templatesDir, function(err, template) {
    winston.info("Setting up templates.", templatesDir);
    if(err) {
        winston.error(err);
    }else{
        var today = new Date().getDay();
        winston.info("Found that today is ", aDays[today]);

        template("notify", {
            reports: [{
                item: "merged",
                desc: "Blah blah"
            },{
                item: "searched",
                desc: "Blah blah"
            }],
            vars: Operators.BBT.mail,
            day: aDays[today],
            fusionAPIRan: canRunFAPI
        }, function(err, html, text) {
            if(err) {
                winston.error(err);
            }else{
                winston.info("Attempting to send an email!");
                smtpTransport.sendMail({
                    from: "Webmaster <webmaster@example.co.uk>",
                    to: "james@example.co.uk",
                    subject: "Worker - Notification Email",
                    html: html
                }, function(error, response){
                    if(error){
                        winston.error(error);
                        cb(false);
                    }else{ 
                        winston.info("Message sent: " + response.message + ", message id: " + response.messageId);
                        cb(true);
                    }
                });
            }
        });
    }
});

It gets as far as Found that today is xxx and the winston.error inside doesn't get called. What's causing that? A dodgy template perhaps?

4

2 回答 2

1

经过大量的挖掘和调试,我设法找到了这个问题的原因。我正在使用node-email-templates,它使用EJS处理 HTML 模板中的 JavaScript 代码,然后使用Nodemailer发送电子邮件。

该问题发生在 EJS 模块中,特别是在尝试处理注释中的变量时。

<!-- The entire job took <%= time => to complete. -->

注释中的代码<%= time %>会导致沿线某处崩溃。我已经 在 EJS 的 GitHub 问题页面上报告了这个错误。当我有时间工作时,我会尝试修复它。

于 2013-04-26T14:35:10.863 回答
0

我遇到了同样的错误,但我的问题是 html2text 将我的一个变量分成两行,比如

<%= var
%>

在更正这一点后,变量都在一行上,我不再得到分配错误。

于 2013-11-04T07:30:16.317 回答