I created a very simple server using Meteor to send an email after a timeout. When I use the timeout, the message is sent successfully, but an error occurs: [Error: Can't wait without a fiber] .
Here is my code:
if (Meteor.isServer) { Meteor.startup(function () { // <DUMMY VALUES: PLEASE CHANGE> process.env.MAIL_URL = 'smtp://me%40example.com: PASSWORD@smtp.example.com :25'; var to = ' you@example.com ' var from = ' me@example.com ' // </DUMMY> // var subject = 'Message' var message = "Hello Meteor" var eta_ms = 10000 var timeout = setTimeout(sendMail, eta_ms); console.log(eta_ms) function sendMail() { console.log("Sending...") try { Email.send({ to: to, from: from, subject: subject, text: message }) } catch (error) { console.log("Email.send error:", error) } } }) }
I understand that I could use Meteor.wrapAsync to create fiber. But wrapAsync expects there will be a callback for the call, and Email.send does not use the callback.
What should I do to get rid of the error?
source share