meteorrn / meteor-react-native

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

Meteor.user() is sometimes undefined on resuming the app from background #148

Closed bratelefant closed 8 months ago

bratelefant commented 8 months ago

On iOS I can observe that in my production / staging env, sometimes I get an undefined Meteor.user() after the app is resume from background. This happened using NetInfo or no NetInfo.

Steps to reproduce the behavior:

  1. Publish Expo App eg. via TestFlight
  2. Let the app suspend to background (eg. not open for several hours) while being logged in
  3. resume your app and notice, that requests do not have logged in user

Expected behavior User should resume the session

Screenshots n/A

Device (please complete the following information): iOS, iPhone 12, 15, iPad 8th gen, iOS 17, recent MeteorRN builds

bratelefant commented 8 months ago

I'll try to come up with a minimal reproduction of the issue. However this seems hard to reproduce.

There seems to be no null-checks on the method call of User._loginWithToken, so a null token value will be saved in Data._tokenIdSaved in any case; maybe this is could be related?

jankapunkt commented 8 months ago

Thanks @bratelefant I will try to get to the bottom of this

jankapunkt commented 8 months ago

By the way I found that logginIn and loggingOut events are not correct:

  _startLoggingIn() {
    this._reactiveDict.set('_loggingIn', true);
    Data.notify('loggingIn');
  },
  _startLoggingOut() {
    User._isLoggingOut = true;
    Data.notify('loggingOut');
  },
  _endLoggingIn() {
    this._reactiveDict.set('_loggingIn', false);
    Data.notify('loggingIn');
  },
  _endLoggingOut() {
    User._isLoggingOut = false;
    Data.notify('loggingOut');
  },

The _endLoggingIn should emit loggedInt and _endLoggingOut should emit loggedOut

molimauro commented 5 months ago

still facing this issue.. @bratelefant is this working on our side now? Ty!

bratelefant commented 5 months ago

I'm currently quite happy with my branch fix/handle-token-login-callback No issues with null users here