私はMeteorを試していて、奇妙なことを見つけました。ドキュメントに記載されているこの例で実験を行っていました(少し変更しました):
if (Meteor.isClient) {
Counts = new Meteor.Collection("counts");
// client: subscribe to the count for the current room
Meteor.subscribe("counts-by-room", '1');
}
if (Meteor.isServer) {
Messages = new Meteor.Collection("messages");
Meteor.publish("counts-by-room", function (roomId) {
var self = this;
check(roomId, String);
var count = 0;
var initializing = true;
var handle = Messages.find({roomId: roomId}).observeChanges({
added: function (id) {
count++;
if (!initializing)
self.changed("counts", roomId, {count: count});
},
removed: function (id) {
count--;
self.changed("counts", roomId, {count: count});
}
// don't care about moved or changed
});
// Observe only returns after the initial added callbacks have
// run. Now return an initial value and mark the subscription
// as ready.
initializing = false;
self.added("counts", roomId, {count: count});
self.ready();
console.log("opened new handle");
// Stop observing the cursor when client unsubs.
// Stopping a subscription automatically takes
// care of sending the client any removed messages.
self.onStop(function () {
console.log("stopping");
handle.stop();
});
});
}
次に、Chrome Dev Console を使用して同じ部屋に複数回登録したところ、サーバー コンソールで毎回新しいハンドルが開いていることがわかりました。サーバーコンソール:
I20130815-14:15:07.470(5.5)? opened new handle
I20130815-14:15:37.661(5.5)? opened new handle
I20130815-14:15:38.616(5.5)? opened new handle
I20130815-14:15:39.191(5.5)? opened new handle
I20130815-14:15:39.703(5.5)? opened new handle
I20130815-14:15:40.215(5.5)? opened new handle
I20130815-14:15:40.711(5.5)? opened new handle
I20130815-14:15:41.207(5.5)? opened new handle
I20130815-14:15:41.704(5.5)? opened new handle
I20130815-14:15:42.200(5.5)? opened new handle
I20130815-14:15:42.696(5.5)? opened new handle
ドキュメントでは、オブザーバーを停止することが非常に重要であると述べているため、それが正常かどうかを知りたいです。誰かが意図的にこれをやろうとしたとき、どうすればそれを止めることができますか。この問題は、おそらくサーバーをダウンさせる可能性のあるある種のメモリリークとして見られます。私が間違っている?
助けてください。私は隕石が初めてです:)