在sgMail.send中编写代码时,msg(Msg)调用会产生错误。如果我离开是作为嵌入式js,它可以很好地工作。
这是错误:
I20190305-07:32:50.195(-8)? Exception while invoking method 'sendEmail' RangeError: Maximum call stack size exceeded
I20190305-07:32:50.196(-8)? at Array.forEach (<anonymous>)
I20190305-07:32:50.196(-8)? at Object.EJSON.clone.v [as clone] (packages/ejson/ejson.js:594:18)
I20190305-07:32:50.196(-8)? at Object.keys.forEach.key (packages/ejson/ejson.js:595:22)
I20190305-07:32:50.196(-8)? at Array.forEach (<anonymous>)
I20190305-07:32:50.196(-8)? at Object.EJSON.clone.v [as clone] (packages/ejson/ejson.js:594:18)
I20190305-07:32:50.196(-8)? at Object.keys.forEach.key (packages/ejson/ejson.js:595:22)
I20190305-07:32:50.196(-8)? at Array.forEach (<anonymous>)
I20190305-07:32:50.196(-8)? at Object.EJSON.clone.v [as clone] (packages/ejson/ejson.js:594:18)
I20190305-07:32:50.196(-8)? at Object.keys.forEach.key (packages/ejson/ejson.js:595:22)
I20190305-07:32:50.196(-8)? at Array.forEach (<anonymous>)
I20190305-07:32:50.196(-8)? at Object.EJSON.clone.v [as clone] (packages/ejson/ejson.js:594:18)
I20190305-07:32:50.196(-8)? at Object.keys.forEach.key (packages/ejson/ejson.js:595:22)
I20190305-07:32:50.197(-8)? at Array.forEach (<anonymous>)
I20190305-07:32:50.197(-8)? at Object.EJSON.clone.v [as clone] (packages/ejson/ejson.js:594:18)
I20190305-07:32:50.197(-8)? at Object.keys.forEach.key (packages/ejson/ejson.js:595:22)
I20190305-07:32:50.197(-8)? at Array.forEach (<anonymous>)
I20190305-07:32:50.197(-8)? => awaited here:
I20190305-07:32:50.197(-8)? at Promise.await (/Users/paulpedrazzi/.meteor/packages/promise/.0.11.2.a0r1i6.m5ai8++os+web.browser+web.browser.legacy+web.cordova/npm/node_modules/meteor-promise/promise_server.js:60:12)
I20190305-07:32:50.197(-8)? at Server.apply (packages/ddp-server/livedata_server.js:1634:14)
I20190305-07:32:50.197(-8)? at Server.call (packages/ddp-server/livedata_server.js:1603:17)
I20190305-07:32:50.197(-8)? at MethodInvocation.sendEmail (server/main.coffee:77:12)
I20190305-07:32:50.197(-8)? at maybeAuditArgumentChecks (packages/ddp-server/livedata_server.js:1767:12)
I20190305-07:32:50.197(-8)? at DDP._CurrentMethodInvocation.withValue (packages/ddp-server/livedata_server.js:719:19)
I20190305-07:32:50.198(-8)? at Meteor.EnvironmentVariable.EVp.withValue (packages/meteor.js:1304:12)
I20190305-07:32:50.198(-8)? at DDPServer._CurrentWriteFence.withValue (packages/ddp-server/livedata_server.js:717:46)
I20190305-07:32:50.198(-8)? at Meteor.EnvironmentVariable.EVp.withValue (packages/meteor.js:1304:12)
I20190305-07:32:50.198(-8)? at Promise (packages/ddp-server/livedata_server.js:715:46)
I20190305-07:32:50.198(-8)? at new Promise (<anonymous>)
I20190305-07:32:50.198(-8)? at Session.method (packages/ddp-server/livedata_server.js:689:23)
I20190305-07:32:50.198(-8)? at packages/ddp-server/livedata_server.js:559:43发布于 2019-03-04 18:19:24
我不认为const是你的问题。在Coffeescript中,你可以直接删除它们。在JS中删除const不会中断之前运行的代码(尽管添加它们可能会)。以下是转换为coffeescript的示例:
sgMail = require('@sendgrid/mail')
sgMail.setApiKey(process.env.SENDGRID_API_KEY)
msg =
to: 'test@example.com'
from: 'test@example.com'
subject: 'Sending with SendGrid is Fun'
text: 'and easy to do anywhere, even with Node.js'
html: '<strong>and easy to do anywhere, even with Node.js</strong>'
sgMail.send(msg)Here you can see the javascript it is converted to
该错误看起来像是无限循环或递归函数调用。
如果您将JS代码转换为Coffeescript,请检查缩进,因为Coffeescript将其用于块而不是大括号。
如果您能找出错误来自哪些行,您就可以发布该代码,以及它被调用的位置。
https://stackoverflow.com/questions/54972301
复制相似问题