New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Subscription overlapping and auto-resubscribe lead to temporary "broken" state #2440
Comments
Yeah, I see what you mean. This is a good point. Not totally sure what the right answer is here. One answer (basically what you said) is: subscriptions that occur within the context of an autorun have their onReady callbacks held back until all subs that were pending for deletion have completely unsubbed. This is a little tricky to implement, but does make sense with the model. |
Is this related to #1173? I think it maybe should be addressed together? |
@mitar I think it's a bit different -- that's purely a problem with reactivity breaking, and the fix is pretty simple I'd guess. I think I actually spotted the problem some time ago but never remembered to bring it up. Sorry! This is a more subtle issue with data appearing wrong for a moment. @n1mmy let me know if you can think of any workarounds apart from "makes sure the different subscriptions publish different records", which can be difficult in practice. |
+1 |
Related problem where auto-resubscribing and getting different values for a document that was subscribed to in both subscriptions results in the observer's changed callback getting invoked after the onReady callback: https://groups.google.com/forum/#!topic/meteor-core/j4Z8Cf3XV_M If we make sure the updated document has a different id, it results in the observer's added callback getting invoked before the onReady as expected. |
Just to be clear. It is not that Am I understanding this correctly? What are use cases when one subscribes to a different subscription as a whole inside autorun? |
As mentioned in #2440 (comment), the chances of this being a problem are pretty low. While there is still an issue here, developer demand to have this fixed has also been quite low. As part of the on-going old issue cleanup process, I'll close this for now. If anyone feels differently (and is interested in working on a patch for this), please let us know. Thanks! |
_1 Upvote_ Suppose you have two subscriptions
a
andb
that bothadd()
to the same document. Then if you have an autorun like:Then, when the guard changes, the following will happen:
b
.b
goes ready. We are now subscribed to botha
andb
. Due to the oft discussed "arbitrary" subscription precedence (e.g. Deep merging of documents #998), temporarilya
's document will win.a
is un-subbed, and we getb
's document.It's surprising because we aren't explicitly subscribing to two subs that publish the same document. And it leads to broken behaviour because the sub goes ready with the "wrong" data.
It's also a pretty common scenario when you consider the same subscription getting called with different reactive arguments.
Repro: https://github.com/tmeasday/publication-auto-override
Perhaps
b
should not become ready untila
has finished unsubbing?The text was updated successfully, but these errors were encountered: