Template-level subscription tainted with another Template's subscription

Here is my use case (suggestions are welcome as to that’s a good idea or not).

  • I have a template that lists All Users (not system/Meteor users)
  • Another template that lists users that match a specific term, using external fuzzy search
  • Fuzzy search is served via ZMQ, request sent, and a list of IDs matched returned
  • I publish the entries matching the IDs given from the ZMQ search agent, publish those select records. Something in the order of ClientUsers.find({_id: {$in: theMatchingIds}})

Since I cannot filter the records on the Client side using normal find({...}) (because the algorithm is not available on the Client), I have to rely solely on the results from the subscription.

The problem now is that when I search for terms that will never match anything, the template will still show records that are matching the ones from the parent template. Remember that there is a higher level template that lists All Users.

Obviously, this is because I use a helper like return ClientUsers.find({}) and hoping to get only the records matching whatever subscriptions is currently for the current template.

How can I force the child template to only use the subscriptions that it has subscribed to, not the subscriptions that other templates are hooked to?

This is a common issue with pub/sub, we discuss it here: https://www.discovermeteor.com/blog/pagination-problems-meteor/

There isn’t a simple solution as far as I know, but there are some packages that try to work around it.

Thanks @sacha. This has been bugging me for quite some time.

As far as I am concerned, this seems to be a legitimate usecase and caused me a lot of headaches as it is really hard to debug when it happens.

Anyone knows if this something has been done about this in Meteor 1.3? At least, there should be options to mark the subscription or the template to not use other cached data.

Of all my time with Meteor, this is really the only problem I think needs a proper/official resolution. All other features are just great.

I’m not aware of anything being done in 1.3 to address this. The best we can do is pray to the mighty Sun God…

Check out this discussion