meteorrn / meteor-react-native

Meteor client for React Native matching Meteor Spec
https://guide.meteor.com/react-native.html
Other
57 stars 31 forks source link

Calling Meteor.reconnect after Meteor.disconnect removes autoReconnection functionality #158

Open bratelefant opened 6 months ago

bratelefant commented 6 months ago

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

  1. Connect a client to a meteor server using the option { autoReconnect: true} (actually not needed, it's true by default).
  2. Call Meteor.disconnect()
  3. Call Meteor.reconnect()
  4. Kill the connection to the server eg by shutting down the server
  5. Bring the server back up
  6. 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.

github-actions[bot] commented 4 months ago

Closing this issue due to no activity. Feel free to reopen.