meteor-react-native
meteor-react-native copied to clipboard
Calling Meteor.reconnect after Meteor.disconnect removes autoReconnection functionality
Describe the bug
If you actively disconnect your client (eg. via AppState events) via Meteor.disconnect()
and then resume the session via Meteor.reconnect()
, the value of autoReconnect
is set to false
, no matter what the initial value was.
To Reproduce
- Connect a client to a meteor server using the option
{ autoReconnect: true}
(actually not needed, it's true by default). - Call
Meteor.disconnect()
- Call
Meteor.reconnect()
- Kill the connection to the server eg by shutting down the server
- Bring the server back up
- Notice that the connection will not get reestablished.
Expected behavior Of course, this is a "contract" issue. In my context, if I control the clients connection actively by disconnecting an app if it is sent to background and reconnect if it is brought back up in foreground, I would assume that in case of a connection drop the connection gets reestablished automatically.
Of course it is expected, that the autoReconnect will no longer happen, when the client is disconnected via Meteor.disconnect()
, thats why in the ddp.js
the value of this.autoReconnect
is set to false.
But if I reconnect using a Meteor.reconnect()
I'd assume that I resume with the same options as I had before Meteor.disconnect()
.
Additional context
I'm currently working on a branch fix/handle-token-login-callback
that addresses a few of minor flaws on connection management in the client, I'll mention this issue in my next commit that also contains a possible fix for this issue.