2013-04-25 4 views
0

내 스크립트가 실패 실패FATAL ERROR : JS 할당 다음과 같은 오류와 함께 템플릿을로드 할 때

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

이 같은 외모를 호출하고있어 코드 :

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 <[email protected]>", 
        to: "[email protected]", 
        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); 
        } 
       }); 
      } 
     }); 
    } 
}); 

그것은 Found that today is xxx까지 도달하고 winston.error은 호출되지 않습니다. 그 원인은 무엇입니까? 아마도 dodgy 템플릿?

답변

1

많은 파고 및 디버깅 작업을 마친이 문제의 원인을 발견했습니다. 나는 EJS을 사용하는 node-email-templates을 사용하여 HTML 템플릿 내에서 JavaScript 코드를 처리 한 다음 Nodemailer을 사용하여 이메일을 보냅니다.

문제는 특히 주석 내에서 변수를 처리하려고 할 때 EJS 모듈 내에서 발생합니다.

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

주석 내의 코드 <%= time %>은 라인 어딘가에서 충돌을 일으 킵니다. EJS의 GitHub 문제 페이지에서 reported this bug을 보았습니다. 나는 직장에서 약간의 시간을 할 때 그것을 고치려고 노력할 것이다.

0

나는이 같은 오류로 실행,하지만 내 문제는 html2text 변수가 모두 한 줄에, 나는 어떤 것을 있도록이를 수정하지 후

<%= var 
%> 

처럼, 두 줄에 내 변수 중 하나를 위반 한 것이 었습니다 더 이상 할당 오류가 발생했습니다.