我有一个使用节点模块 MQTTClient 的流星应用程序。
每当将某些内容发布到客户端订阅的主题时,此客户端都会发送事件。
当事件发生时,我想更新集合中的条目,但是当我这样做时,我得到断言失败并且数据库被损坏。
Assertion failed: (handle->InternalFieldCount() > 0), function Unwrap, file ../src/node_object_wrap.h, line 61.
Exited from signal: SIGABRT
Your application is crashing. Waiting for file change.
这是我目前拥有的:
...
client.connect(function () {
console.log('connected to MQTT broker');
Fiber(function(){
var allTopics = Topics.find({});
allTopics.forEach(function(topic){
console.log('subscribing to ' + topic.name);
client.subscribe(topic.name);
});
}).run();
});
var onPublish = function(topicName, payload, message_id) {
console.log("New message: " + topicName + ":" + payload);
Topics.insert({name: payload, value: payload});
};
var wrappedOnPublish = Meteor.bindEnvironment(onPublish, function(e){
var message = "Something went wrong! " +
"Everything is broken! " +
"Your life is ruined!";
console.log(message, e.stack);
});
client.on('publish', wrappedOnPublish);
我还尝试通过将回调包装在 Fiber(..).run() 中来处理回调,但发生完全相同的错误。