meteor-react-native icon indicating copy to clipboard operation
meteor-react-native copied to clipboard

Calling Meteor.reconnect after Meteor.disconnect removes autoReconnection functionality

Open bratelefant opened this issue 1 year ago • 1 comments

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.

bratelefant avatar Feb 20 '24 16:02 bratelefant