Amplify-js: Upgrading Amplify packages stops remembering Auth session in React Native

Created on 12 Nov 2019  路  16Comments  路  Source: aws-amplify/amplify-js

Describe the bug
Yesterday I've updated my React Native app to the latest version of amazon-cognito-identity-js, @aws-amplify/auth and @aws-amplify/core. Unfortunately after updating the packages my app didn't remembered the Cognito session anymore after killing the app (so swiping it up on iOS).

It happens on both development and production mode.

  • @aws-amplify/auth from 1.4.2 to 1.5.0
  • @aws-amplify/core from 1.2.2 to 1.2.4
  • amazon-cognito-identity-js from 3.1.2 to 3.2.0

I'd read the change log and commit messages of both packages, but couldn't find anything that might be related to the issue. Is this a known bug, or did I miss anything in the change log?


Environment
System: OS: macOS 10.15.1 CPU: (4) x64 Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz Memory: 50.67 MB / 8.00 GB Shell: 5.7.1 - /bin/zsh Binaries: Node: 12.13.0 - ~/.nvm/versions/node/v12.13.0/bin/node Yarn: 1.10.1 - /usr/local/bin/yarn npm: 6.12.0 - ~/.nvm/versions/node/v12.13.0/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman Browsers: Chrome: 78.0.3904.97 Firefox: 70.0 Safari: 13.0.3 npmGlobalPackages: npm: 6.12.0 react-native-cli: 2.0.1

Smartphone (please complete the following information):

  • Device: iPhoneX
  • OS: 13.1.3

Sample code
After I've re-opened the app I run Auth.currentAuthenticatedUser() on componentDidMount, which returns a "not authenticated".

to-be-reproduced

Most helpful comment

Could you delete your node_modules and do:

npm install aws-amplify@next

Let us know if this resolves your issue. We will add the fix to @latest early next week.

All 16 comments

You have to create your own Store.
AsyncStorage is not in react native anymore.

@davidbiller I don鈥檛 think this has anything to do with React Native since I already was on the latest version. I happend only because I鈥檇 update to the most recent AWS packages

Hi @rnnyrk could you share the version of react native you are using? Also were you using the same version before the upgrade?

@Ashish5591 I do run react-native 0.61.4. This works with the old versions of the AWS packages mentioned in the first post, but after upgrading the AWS packages I encounter the described issues with the the same react-native version.

I'm experiencing similar issue, Auth.currentAuthenticatedUser() throws an error not authenticatedafter the app refresh. Any updates about this issue?
https://github.com/aws-amplify/amplify-js/issues/4420

@Luckygirlllll do you encounter the same issue if you provide custom storage in you amplify configuration for Auth?

@rafauke I just have updated AsyncStorage and I see the same problem.

@rafauke I just have updated AsyncStorage and I see the same problem.

It鈥檚 not necessary to update the asyncStorage. You have to provide the storage to the aws amplify config.

@davidbiller Got it, I used the answer from this issue, after the adding storage to amplify config it started work correctly,

Could you delete your node_modules and do:

npm install aws-amplify@next

Let us know if this resolves your issue. We will add the fix to @latest early next week.

Thank you! Unfortunately I can鈥檛 try it out until Monday.

Awesome, it worked after updating to aws-amplify@next
Tested on iOS.
Thanks!

@Ashish-Nanda Confirmed that it works again after updating to @aws-amplify/auth@next and @aws-amplify/core@next without adding the custom storage helper, suggested in https://github.com/aws-amplify/amplify-js/issues/4351 and the AWS docs. Both running 2.1.0 now. Any idea when this will get stable?

Hi @rnnyrk and @lzbikowski-opensource the fix is in @latest now.

If you can confirm its working, I'll go ahead and close the issue.

Since this comment as well as a few others on that thread were able to confirm that the fix in @latest resolves the problem, I'm going to go ahead and close this issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

leantide picture leantide  路  3Comments

cosmosof picture cosmosof  路  3Comments

rayhaanq picture rayhaanq  路  3Comments

callmekatootie picture callmekatootie  路  3Comments

DougWoodCDS picture DougWoodCDS  路  3Comments