Hi Everyone,
I have a problem that’s been bugging me for several weeks already.
In my app I have a collection called StateCollection
and I publish it like this:
return StateCollection.find({
mac: mac
});
The documents are rather big, but I use all the data, so I don’t have any fields
section - I use all of the data. The mac
filter is just to show data that relate to the current user (similar as if I used userId
).
It used to work OK for a long time, but recently what started happening is that some parts of the document won’t arrive on the client. If I log the documents server side, they are OK, but on the client side, some of the “sub-documents” are missing. This may not be relevant, but specifically, the documents have a field called status
, which is an object and it’s supposed to contain (among other stuff) another object called system
. And that’s the problematic part. This system
field is completely missing on the client side (although if I debug-print the document server side inside the publication function, it’s all OK).
Now I think this has something to do with collection merging which is potentially faulty. Here’s why:
At some point I added a different publication that’s intended for Admins to get some overview of the user data. This one is called lastUsersActivity
It looks like this:
return StateCollection.find({}, {
fields: {
"mac": 1,
"status.lastUpdated": 1,
"lastDataUpdate": 1
}
});
I.e. it does no filtering (fetches all the users), but it only gets some minor portion of the documents (especially notice the status.lastUpdated
field).
Now the problem I’ve described above only happens if the lastUsersActivity
publication is used before state
publication, i.e. if the admin first loads a page that uses lastUsersActivity
and only then opens another page, that subscribes to state
publication. In the opposite order there is no problem.
So, my guess is that somehow meteor thinks that user who subscribed to lastUsersActivity
already has those data and does not propagate those to the client. That is however not true… If you look at the definition, only status.lastUpdated
is sent not, the entire status
object. And that may be the reason why status.system
is missing.
Can anyone confirm if this could be a problem?
Also, I’ve read all the articles on subscription / publication stuff, like the docs or this one and watched all tutorials I could find but none of those mentions this kind of problem.
This is meteor 2.2. I would spend the effort of migrating (I’m rather afraid of what it might break) if I knew the problem was addressed, but I found on such mention in the changelog.
Would appreciate any help I can get…
Thanks!