sendgrid sgmail.使用咖啡网流星对错误进行错误.作为纯JS的正常工作正常



sgmail.send(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

我不认为const是您的问题。在Coffeescript中,您可以将它们删除。在JS中删除const不能破坏以前运行的代码(尽管添加它们可能可以)。这是您的样本转换为咖啡文字:

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)

在这里您可以看到JavaScript转换为

错误看起来像无限循环或递归功能调用。

如果将JS代码转换为Coffeescript,请检查您的缩进,因为Coffeescript将其用于块而不是支撑。

如果您可以弄清楚错误来自哪个行,则可以发布该代码,以及该代码。

相关内容

最新更新