Meteor.publish(null, f) now starts universal subscriptions for all existing
sessions (as well as future sessions). Fixes#583. Care is taken when a session
is re-running its subs.
Re-running subs is now implemented by "deactivating" the _LivedataSubscription
object and re-creating a new one instead of "resetting" it in place. This allows
us to ensure that old publish handlers have no access to the merge
boxes (SessionCollectionViews) because deactivated _LivedataSubscriptions ignore
callbacks. Thus, we can be assured that after deactivating all subscription, the
merge box really cannot be affected by old publishers continuing to run.
Note: if a publish function has not even finished its original handler run (eg,
if running setUserId in parallel to a universal subscription, which runs in a
separate fiber from the message-handling loop), the old publish function *WILL*
continue to run (both before and after this commit). However, with this commit,
any attempt by the old publish function to call publisher methods will be
ignored instead of being perhaps-inconsistently interpreted. If a publisher
really needs to know if it has been stopped before it has finished running the
handler, it can set an onStop callback before it does anything that can yield.
- If a subscription is stopped before it has fully started (eg, a universal
publisher that has yielded, or a destroy()ed session), call the stop callback
immediately in onStop, so as to not leak resources.
- In _setUserID, don't set _isSending to false until after running the stop
callbacks for all subs; if a stop callback yielded, CollectionViews could have
been mutated without sending messages.
- Annotate the collection-diffing code with _noYieldsAllowed.
Previously, had only switched over the default for minimongo --
so there's lots of stuff that actually didn't work.
With this change, two tests are still failing; I will fix them and
then do some more cleanup tomorrow.
... but preserve other types on the outside of minimongo.
So far passing all current regression tests, but moment of truth
when we switch over to ObjectID yet to come.
This is a first pass for now; it doesn't support all the types
we will eventually support, and it may be in flux in terms of the exact
format for a little while yet. Also I need to write tests.
But the outline is there.
to mean that the field was cleared, instead of a separate clear list.
Wire format will still have separate clear list
Next step is making a similar change on the client.