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
User logging in or out overwrites onReconnect and code using onReconnect breaks resume-on-reconnect #5665
Comments
Hey @brettle, thanks for the clearly explained issue. You're right -- we document the I'm curious to know what your use-case is. Can you elaborate on that? If I were to make this change I wouldn't even keep |
Hi @avital. I have 2 specific use cases at the moment. Use case 1: I'm working with @splendido and @zimme on a new accounts system that we hope will eventually be integrated into core. The basic idea of the new system is that it will separate creation of an identity from the creation of an account. An identity is conceptually similar to the current concept of a service account. You might have multiple Google identities, and a password identity and they could all be used to access the same account. Anyway, I would like to be able to support using the existing login services (of which there are many) to create identities instead of accounts. To do that, the client would put the connection in create-identity-not-account mode (via a method call) and then call the desired Use case 2: One of the issues with the current account system is that Regarding Regarding Let me know if you have any other questions and whether my plan sounds reasonable. I'd like to start work on the PR soon. |
Thanks for explaining this. Honestly how you describe the design for these new packages sounds a little contorted to me, but maybe that's the best option given our current accounts system. Thanks for reminding me about the I'm not sure we should care too much about backwards compatibility. If 3rd party packages used Meteor releases aren't semver. We definitely break APIs between Meteor releases. But we should aim to keep package versions semver-compliant. |
The implementations I described are definitely contorted but yes that is due to the limitations of the current accounts system. This is all under the covers though. The API for these packages will (hopefully) be pretty easy to understand. Yes, 3rd party packages which currently use FWIW, here's a hackish way to achieve backward compatibility: Have The more I think about this, the more I think it would be better to just put the new functionality under a name other than |
@avital, we're currently working on these document to try and describe the behaviours and api we expect and want. Also, how high would the likelihood be that a new accounts system would be accepted into core that have almost no backwards compatibility? The reason I ask is because during our talks around a new accounts system I've felt several times that it maybe would just be better to make a new accounts system edit: feel free to remove if you think it's too off topic. |
Deprecate use of `connection.onReconnect = func`. Instead, a new `DDP.onReconnect(callback)` method should be used to register callbacks to call when a connection reconnects. The connection that is reconnecting is passed as the only argument to `callback`. This is used by the accounts system to relogin on reconnects without interfering with other code which uses `connection.onReconnect`.
@avital, the PR I just added takes the |
I just noticed that on the server-side there is |
Just my 2 cents, but if any package is using Therein deprecating it or removing it entirely isn't a bad idea (as how it was documented, it never worked to begin with.) |
@AlbinoGeek, I think it is possible for a package to use the If you meant that Meteor 1.2 would break the package instead of the other way around, the answer is yes, but only if the package/app uses the Meteor accounts system. For example, it looks like the vertretungsplan-handrup app uses FWIW, I found the above 2 examples with this github search. It turns up a bunch of false positives, but it seems unlikely that these are the only examples. Also, this issue appears to have been around since way before Meteor 1.2. For example the accounts system seems to have had this same issue since at least November 2012. Anyway, I agree that the current syntax should be deprecated. The question is whether the new syntax should be |
@brettle Thanks for the explanation, and the link to github search; I completely forgot that was a thing. I agree with you on the ".. use a different syntax for the new functionality .." part, as it would avoid breaking any code that used the previous method (and we should print a deprecation warning if they attempt to use the old functionality, else they would silently fail and package authors and users alike wouldn't know why.) For example, with the new syntax; if I was a package author (or used a package) that implemented the |
FYI, the PR I created for this bug is PR #5677. I thought mentioning the issue number in the commit message would make github link to it here, but I guess not. |
@brettle it links when it's merged and in the commit history of the repo =) |
+1 for changing it to As an author of a package that uses Also, I can confirm that the user logging in or out breaks my package by overwriting
|
+1 |
One can overcome the issue with observing changes in Meteor.status()
this will always trigger on every reconnect |
Hi all - just blowing this dust off this one a bit. I know it's been a while, but I think there is definitely still value in getting these changes in (especially since |
* Fix bug #5665: add DDP.onReconnect(), deprecate conn.onReconnect Deprecate use of `connection.onReconnect = func`. Instead, a new `DDP.onReconnect(callback)` method should be used to register callbacks to call when a connection reconnects. The connection that is reconnecting is passed as the only argument to `callback`. This is used by the accounts system to relogin on reconnects without interfering with other code which uses `connection.onReconnect`. * Adjust History entry, package versions, code cleanup
_1 Upvote_ The docs say that
connection.onReconnect
can be used to set "a function to be called as the first step of reconnecting." However, if the user logs in or out using the connection, the accounts system will overwrite anyonReconnect
function that has been set. This overwriting occurs here and here. There is also the related issue that other code settingconnection.onReconnect
will cause the resume-on-reconnect functionality to stop working.If you really need a reproduction repo, I can put one together, but I'd prefer to just include appropriate tests in a PR which fixes the problem.
Here's the fix I propose:
connection.onReconnect
.connection.onReset(callback)
method that registerscallback
as one of potentially several callbacks to be called when the connection is reset/reconnected (in addition to callingconnection.onReconnect()
. LikeonLogin
, etc.connection.onReset(callback)
would return an object with astop()
method that could be used to unregister the callback.AccountsClient.callLoginMethod
to callonReset(callback)
instead of settingonReconnect
, so that other code can't break the resume-on-reconnect functionality.Would a PR along these lines be considered?
The text was updated successfully, but these errors were encountered: