从服务器上的Meteor集合中获取项目将引发“无法等待没有光纤”

我正在做一个相当简单的meteor应用程序,第一次应该查询所有从某个回购协议的git问题。 从github api获取问题清单之后,其想法是从这些问题中创build一个任务集合。 但是,每当我尝试查询当前任务的列表,我得到:

.../.meteor/tools/c2a0453c51/lib/node_modules/fibers/future.js:83 W20140418-17:00:43.872(-7)? (STDERR) throw new Error('Can\'t wait without a fiber'); W20140418-17:00:43.872(-7)? (STDERR) ^ W20140418-17:00:43.889(-7)? (STDERR) Error: Can't wait without a fiber W20140418-17:00:43.889(-7)? (STDERR) at Function.wait (.../.meteor/tools/c2a0453c51/lib/node_modules/fibers/future.js:83:9) W20140418-17:00:43.890(-7)? (STDERR) at Object.Future.wait (.../.meteor/tools/c2a0453c51/lib/node_modules/fibers/future.js:325:10) W20140418-17:00:43.890(-7)? (STDERR) at _.extend._nextObject (packages/mongo- livedata/mongo_driver.js:805) W20140418-17:00:43.890(-7)? (STDERR) at _.extend.forEach (packages/mongo-livedata/mongo_driver.js:836) W20140418-17:00:43.890(-7)? (STDERR) at Cursor.(anonymous function) [as forEach] (packages/mongo- livedata/mongo_driver.js:695) W20140418-17:00:43.890(-7)? (STDERR) at app/server/publish.js:51:33 W20140418-17:00:43.890(-7)? (STDERR) at Array.forEach (native) W20140418-17:00:43.891(-7)? (STDERR) at app/server/publish.js:49:19 W20140418-17:00:43.891(-7)? (STDERR) at ...packages/npm/.build/npm/node_modules/github/api/v3.0.0/issues.js:116:17 W20140418-17:00:43.891(-7)? (STDERR) at IncomingMessage.<anonymous> (...packages/npm/.build/npm/node_modules/github/index.js:756:21) 

我的第一个想法是,当我使用节点光纤时,我正在使用callback,但代码看起来相对简单:

 var repos = ['my-repo', 'my-repo-1',]; var pollGit = function() { repos.forEach(function(repo) { github.issues.repoIssues({ user: 'user', repo: repo }, function(err, stuff) { if (err) { throw err; } stuff.forEach(function (issue) { var sel = {git_id: issue.id}; Tasks.find(sel).forEach(function (item) { //ERROR THROWN HERE console.log('got', item); }); }); }); }); }; Meteor.startup(function() { pollGit(); }); 

这个错误发生在任何时候我试图调用查找后获取实际的对象。 只要调用find()就可以。 究竟是什么导致了错误?

回答我自己的问题,以防有人需要答案:

知道如何在光纤中插入集合?

代码如下:

 Fiber = Npm.require('fibers'); var repos = ['my-repo', 'my-repo-1',]; var pollGit = function() { repos.forEach(function(repo) { github.issues.repoIssues({ user: 'user', repo: repo }, function(err, stuff) { if (err) { throw err; } stuff.forEach(function (issue) { var sel = {git_id: issue.id}; Fiber(function() { Tasks.find(sel).forEach(function (item) { //ERROR THROWN HERE console.log('got', item); }); }).run(); }); }); }); }; Meteor.startup(function() { pollGit(); });