MongoError:游标被杀死或超时-Meteor超时设置无效
MongoError: cursor killed or timed out - Meteor timeout settings ineffective
我的Meteor 1.2.1程序在find().forEach()
循环中抛出了MongoError: cursor killed or timed out
,所以我找到了这个页面,上面写着这个代码可以防止:
var myCursor = db.users.find().noCursorTimeout()
然而,驱动程序文档和我的Meteor说这个方法不存在:Object [object Object] has no method 'noCursorTimeout'
Mongo autoReconnect是默认启用的,没有任何帮助,Meteor论坛,甚至.find({}, {timeout:false})
也没有。
2016-07-20 11:21:37更新启动
2016-07-20 11:37:21调用方法"updateCollections"MongoError时出现异常:游标被杀死或超时
也许Meteor被2016-07-20 09:34:57失败的SOAP调用弄糊涂了?
"error": {
"errno": "ETIMEDOUT",
"syscall": "connect",
"code": "ETIMEDOUT"
},
假设maxTimeMS
在这种情况下会有所帮助,您可以通过使用rawCollection
对象而不是Meteor集合本身来访问它。
很简单:
var rawCollection = Meteor.users.rawCollection();
var cursor = rawCollection.find({}).maxTimeMS(5000);
var myData = fetchCursor(cursor);
其中fetchCursor
是一个简单的光纤感知辅助功能,可以这样实现:
var fetchCursor = Meteor.wrapAsync(function fetchCursor (cursor, cb) {
cursor.toArray(cb);
});
不过,我不确定这种方法是否正是你想要的。
编辑
如果你不需要整个文档阵列,但你想独立处理其中的每一个,那么最好使用each
而不是toArray
,例如
var fetchCursor = Meteor.wrapAsync(function fetchCursor (cursor, cb) {
cursor.each(function (err, doc) {
if (err) return cb(err);
if (!doc) return cb(null, { done: true }); // no more documents
// do something with the document ...
});
});
相关文章:
- Meteor如何接收HTTP请求
- Meteor-将选定窗体中的对象添加到集合中
- Meteor上的启动页面
- Meteor方法在客户端返回null,在客户端运行的相同方法返回正确的值
- Meteor-添加用户自定义字段的方法不起作用
- Meteor忘记了密码的实现
- 链接所有<a>Meteor
- 在Meteor项目中安装并包含npm模块后出错
- Meteor JS中代码的重复使用部分
- Meteor Router数据函数被调用两次
- 基于localStorage的Meteor激活模板
- React+Meteor:this.ops返回未定义
- 如何将PHP get查询转换为Meteor's HTTP.get()
- 使用优化器在慢速连接上加载main.js时需要js超时
- 如何将javascript变量传递到Meteor Spacebars模板中
- 部署时使用npm包时发生Meteor错误
- Meteor如何运行服务器端python脚本
- 谷歌地图根本不适用于Meteor-iOS
- 使用Velocity和Jasmine测试Meteor时需要超时
- MongoError:游标被杀死或超时-Meteor超时设置无效