没有光纤就等不及了

时间:2013-10-03 19:11:31

标签: meteor

我使用node-imap meteor包来检索电子邮件,然后使用该电子邮件在Guests集合中查找来宾。我得到"等不会出现光纤错误"当我包含Guest.findOne代码时。这是代码

        function openInbox(cb) {             
            imap.openBox('INBOX', true, cb);              
        }
        imap.once('ready', function() {
         openInbox(function(err, box) {
          if (err) throw err;
          var f = imap.seq.fetch(box.messages.total + ':*', { bodies: ['HEADER.FIELDS (FROM SUBJECT DATE)','TEXT'] });
          f.on('message', function(msg, seqno) {
            console.log('Message #%d', seqno);
            var prefix = '(#' + seqno + ') ';
            msg.on('body', function(stream, info) {
              if (info.which === 'TEXT')
                console.log(prefix + 'Body [%s] found, %d total bytes', (info.which), info.size);
              var buffer = '', count = 0;
              stream.on('data', function(chunk) {
                count += chunk.length;
                buffer += chunk.toString('utf8');
                if (info.which === 'TEXT')
                  console.log(prefix + 'Body [%s] (%d/%d)', (info.which), count, info.size);
              });
              stream.once('end', function() {
                if (info.which !== 'TEXT') {
                  console.log(prefix + 'Parsed header: ');
                  var header = Imap.parseHeader(buffer); 
                  var from = header.from;
                  email = from[0].slice(from[0].indexOf('<')+1, from[0].indexOf('>'));
                  fetched = true;
                }
                else
                  console.log(prefix + 'Body [%s] Finished', (info.which));
              });
            });
            msg.once('attributes', function(attrs) {
              console.log(prefix + 'Attributes: %s', (attrs, false, 8));
            });
            msg.once('end', function() {
              console.log(prefix + 'Finished');
            });
          });
          f.once('error', function(err) {
            console.log('Fetch error: ' + err);
          });
          f.once('end', function() {
            console.log('Done fetching all messages!');
            imap.end();
             if(fetched){
                  var guest = Guests.findOne({email: email}, {reactive: false}); // <-- this code causes the error
                  if(guest){
                    console.log(guest)
                  }
                }
          });
        });
      });
      imap.once('error', function(err) {
        console.log(err);
      });
      imap.once('end', function() {
        console.log('Connection ended');
      });
      imap.connect();

所以我尝试根据Future.wait() can't wait without a fiber (while waiting on another future in Meteor.method)

做一个Meteor.bindEnvironment
    function openInbox(cb) {
        imap.openBox('INBOX', true, Meteor.bindEnvironment(cb));
    }

并收到错误消息&#34;无法读取属性&#39; _meteor_dynamics&#39;未定义&#34;。那么没有光纤可以绑定到?我仍然是Meteor的新手,所以不知道从哪里开始。对正在发生的事情和解决方案的解释会很棒。任何帮助表示赞赏。

0 个答案:

没有答案