parse-community / ParseReact

Seamlessly bring Parse data into your React applications.
https://parseplatform.org
Other
1.3k stars 209 forks source link

Fixing the Logout/currentUser race condition. #179

Closed MonirAbuHilal closed 7 years ago

MonirAbuHilal commented 8 years ago

This code change fixes a race condition in the overriden Parse.User.logOut() method.

The logOut() method is supposed to reset the current user to null but the code path is not waiting for the oldLogOut() promise result to update the currentUser state in the local subscriptions module (LocalSubscriptions.js) which causes the LocalSubscription.currentUser.update() method to call the setCurrentUser(...) with the stale user object.

Example


Parse.User.logOut()
          .then(() => Parse.User.currentAsync())
          .then((user) => { console.log("Current User", user); });

The JS code snippet above is supposed to log "null" as the value of the user parameter, but it's logging the old stale user object all the time.

MonirAbuHilal commented 8 years ago

Fixes: #161

TonyTangAndroid commented 7 years ago

When this pull request will be merged?