【发布时间】:2014-04-03 19:13:03
【问题描述】:
在 Meteor.binEnvironment 中已经存在的函数中,当我运行 <collection>.find ({}) 时,我收到错误 throw new Error ('Can \' t wait without a fiber ');
如果您将该调用也放在Meteor.bindEnvironment(<collection>.find ({})) 中,则错误消息将变为:throw new Error (noFiberMessage);
有问题的函数贯穿Meteor.methods ({})
我哪里错了?
重现错误的示例:
Meteor.methods({
"teste" : Meteor.bindEnvironment(function(){
var Future = Meteor.require('fibers/future');
var future = new Future();
setTimeout(function(){
return future.return(Sessions.findOne({}))
}, 15000);
console.log('fut', future.wait());
})
});
【问题讨论】:
-
我不知道这是否解决了您的实际问题,但在您的示例中,无需使用
Meteor.bindEnvironment,只需使用Meteor.setTimeout而不是setTimeout(Meteor.setTimeout将使用Meteor.bindEnvironment为您服务)。
标签: meteor node-fibers