我正在使用鳕鱼npm包来获取collaborative chess game

它以非常灵活的方式编写,似乎我必须像这样使用它:

Evaluator = (function() {
  var Promise = Meteor.npmRequire('promise');
  var ev = Meteor.npmRequire('stockfish')();
  var promise = new Promise(function (resolve, reject) {
    var line;
    ev.onmessage = function(e) {
      if (e && typeof e === "object") {
          line = e.data;
      } else {
          line = e;
      }
      if (line.indexOf('Total Evaluation') > -1) {
        var score = parseFloat(line.split('Total Evaluation: ')[1].split('(')[0])
        resolve(score);
      }
    };
  });


  return function(movesStr) { 
    ev.postMessage('position startpos moves ' + movesStr);
    ev.postMessage("eval");
    return promise;
  }

})();

并称之为:

Meteor.methods({
  evaluate: evaluate
});

function evaluate(movesStr) {
  return Evaluator(movesStr);
}

所以从我的模型来看,调用看起来像这样:

Meteor.call('evaluate', movesStr)
    .then(function(gameScore) {
      log('gameScore', gameScore);
      Games.update(
        { _id: gameId },
        { $set: { score: gameScore } },
        function(err, docs) {
          log('cacheGameScore', 'err', err)
        }
      );
    });

这段代码“有效”,我可以在控制台上看到准确的结果 .

但是DB调用

Games.update

触发此错误:

[Error: Meteor code must always run within a Fiber. 
Try wrapping callbacks that you pass to non-Meteor 
libraries with Meteor.bindEnvironment.]

我试过在很多地方添加Meteor.wrapAsync和Meteor.bindEnvironment,我总是得到这个错误信息 .

在这里尝试的任何想法?