Closed vahdet closed 3 years ago
I haven't fully ingested this yet, and I'm not really familiar with Expo, but here's an article that suggests this is not a production-time bug, and it's related specifically to serving an "ejected" expo app from expo server: https://ajenkins.me/post/dating_app_update_1
I figured out that this is coming from the react-native-get-random-values package, which is a dependency of aws-amplify. ... The silver-lining is that this issue only manifests when I run the app using Expo, not when I run it with the iOS simulator, which implies to me that it's not a "real" bug and would never be encountered by a real user.
@vahdet, can you confirm whether your experience aligns with this?
I ran this same error on my Expo (React Native) project that I've been developing long time. I upgraded to latest Expo SDK 41, which was released last week, and my authentication broke down. I also know what problem is. It is Expo deprecating *.expo.js
filetype handling, which amazon-cognito-identity-js
is using.
This is stated in Expo update blog post:
https://blog.expo.io/expo-sdk-41-12cc5232f2ef#6bab
And here is more in-depth details about this change:
https://github.com/expo/fyi/blob/master/expo-extension-migration.md
How to reproduce this problem:
I hope this information helps to get amazon-cognito-identity-js updated.
@vahdet
There is workaround for time being for Expo SDK 41 users, while we wait library providers like AWS Amplify to make changes in their libraries.
When starting expo-cli, pass EXPO_LEGACY_IMPORTS=1 as environment variable to it. For example:
EXPO_LEGACY_IMPORTS=1 expo-cli start
That enabled my project to continue function for time being.
@kerbe Hmm. I tried running expo start
with environment variable EXPO_LEGACY_IMPORTS
with value 1
added on the system, however, exact the same error keeps showing up. Btw, when I google _EXPO_LEGACYIMPORTS hardly any results come up, do the docs mention this variable or am I missing something?
@svidgen Actually, I did not eject Expo from my project..
When I run expo upgrade
I see this:
✖ Found project files with deprecated features Project is using deprecated .expo.* file extensions. Please refactor the following files and upgrade modules accordingly:
- /Users/headj/Sites/app2/node_modules/amazon-cognito-identity-js/es/utils/getRandomBase64.expo.js
- /Users/headj/Sites/app2/node_modules/amazon-cognito-identity-js/lib/utils/getRandomBase64.expo.js
- /Users/headj/Sites/app2/node_modules/amazon-cognito-identity-js/src/utils/getRandomBase64.expo.js
When I run EXPO_LEGACY_IMPORTS=1 expo start
it works, but with this warning:
Dangerously enabled the deprecated
.expo
extensions feature, this functionality may be removed between SDK cycles.
@vahdet that EXPO_LEGACY_IMPORTS=1
was presented when I ran expo upgrade
from SDK 40 project to SDK 41 project. This is what it output at that time:
✔ Installed node_modules and rebuilt package-lock.json.
✔ Cleared packager cache.
✖ Found project files with deprecated features
Project is using deprecated .expo.* file extensions.
Please refactor the following files and upgrade modules accordingly:
- /app/node_modules/amazon-cognito-identity-js/es/utils/getRandomBase64.expo.js
- /app/node_modules/amazon-cognito-identity-js/lib/utils/getRandomBase64.expo.js
- /app/node_modules/amazon-cognito-identity-js/src/utils/getRandomBase64.expo.js
Dangerously disable this check with EXPO_LEGACY_IMPORTS=1
Learn more: http://expo.fyi/expo-extension-migration
👏 Automated upgrade steps complete.
...but this doesn't mean everything is done yet!
Expo has quite many environment variables it takes on startup. But pretty much none is documented properly anywhere. You get to those usually just by reading either Expo's source code, or asking help in issues with really specific use case, then you're told about such environment variable that does magic for you. 😁
tl;dr PowerShell not handling EXPO_LEGACY_IMPORTS=1 expo start
may not imply it is a wrong command
Ok, I have a Windows workstation and when I run the command EXPO_LEGACY_IMPORTS=1 expo start
in the defaul PowerShell terminal, it threw:
PS > EXPO_LEGACY_IMPORTS=1 expo start
EXPO_LEGACY_IMPORTS=1 : The term 'EXPO_LEGACY_IMPORTS=1' is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ EXPO_LEGACY_IMPORTS=1 expo start
+ ~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (EXPO_LEGACY_IMPORTS=1:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Then, I tried running that line on Git Bash instead, it worked and I could perform sign in without an error.
As @kerbe stated, there is no clear cross-platform commands for it on Expo docs; so, I stick with Git Bash and move ahead 😄
Thanks @webjay & @kerbe for the guidance! I am not sure if this workaround is enough for closing the issue, so I leave the decision to the repo owners. All in all, amazon-cognito-identity-js
code apparently needs modifications for an ultimate solution.
tl;dr PowerShell not handling
EXPO_LEGACY_IMPORTS=1 expo start
may not imply it is a wrong command
I think if you use PowerShell, you set environment variable like this:
PS> $env:EXPO_LEGACY_IMPORTS=1; expo start
Syntax I gave earlier is for different unix variants, so it works in Git Bash as you used, but also in WSL distros and such. I've actually dockerized expo-cli, and use that to keep whole development environment similar on all computers I work on.
And yea, this is just workaround for time being, actual code needs modifications. This env variable might be removed in future Expo releases, and as it is Expo specific code in this repo, it just needs to be updated.
So how exactly do you fix it? Copy and paste the code under "Manual Configuration" into my project?
FYI I got this too, I'm on RN without Expo. It was resolved after I installed and linked amazon-cognito-identity-js
.
I had that module deep within my node modules, in node_modules/@aws-amplify/auth/node_modules/amazon-cognito-identity-js
, but I guess dependencies' dependencies aren't automatically linked.
I am still having the same issue with Expo 41.0.0
and amplify 3.3.27
. Update to use 3.3.28 unstable solves the issue
I am still having the same problem with the Auth.SignIn function. Have tried all the above solutions plus removing aws-amplify, amazon-cognito-identity-js, and reinstalling. Deleting node_modules and reinstalling. Any ideas where I could be going wrong?
expo: 41.0.1 amazon-cognito-identity-js: 4.6.0 aws-amplify: 3.3.27
With help from this Stackoverflow answer and as a temporary workaround, I've been able to use legacy imports when running expo
commands, for example:
EXPO_LEGACY_IMPORTS=1 expo start
EXPO_LEGACY_IMPORTS=1 expo export --public-url https://myurl.com
This obviously isn't ideal, but at least gets past the issue until the expo and amplify libraries sync up with their imports.
@kerbe Hmm. I tried running
expo start
with environment variableEXPO_LEGACY_IMPORTS
with value1
added on the system, however, exact the same error keeps showing up. Btw, when I google _EXPO_LEGACYIMPORTS hardly any results come up, do the docs mention this variable or am I missing something?
Literally write EXPO_LEGACY_IMPORTS=1 expo-cli start
A good workaround is to just run EXPO_LEGACY_IMPORTS=1 expo-cli start
instead of "expo start"
EXPO_LEGACY_IMPORTS=1 expo-cli start
isnt working for me does anyone know any other work arounds?
As of 2021-05-06, 4:30pm (Pacific time), EXPO_LEGACY_IMPORTS=1 expo-cli start
isn't working. Will update if I find a solution.
@danielson9 & @EvanErickson you need to be a bit more specific, how it doesn't work? I have just updated my own project, so it uses latest amazon-cognito-identity-js: 4.6.1
. And my Auth.signIn
works fine, with and without EXPO_LEGACY_IMPORTS=1
.
So first try updating to latest version, and if problem persist, more information would be appreciated. I at least can't currently reproduce any further problems.
hello! i'm from the expo team. sorry we missed this library, we tried to track down usages of the .expo.js
extension and updated them wherever we found them, but i didn't think to check amplify-js and send a pull request to fix it.
thank you @svidgen for resolving this in https://github.com/aws-amplify/amplify-js/commit/2d4052da555709fe0f759fecb2df4b4b9604461c
i can confirm that if you set the EXPO_LEGACY_IMPORTS=1
environment variable this will resolve the issue temporarily, but keep in mind that you need to also set that value when you publish your app. it's best to update to the latest version that includes the fix.
Still doesn't work. @brentvatne It gives me an auth error. I tried updating my expo cli and the package json but it still gives me problems. Any ideas?
@EvanErickson I might not be best to help, but you could double check your installed version with this:
npm ls --depth=2 | grep "amazon-cognito"
It should print out:
│ ├─┬ amazon-cognito-identity-js@4.6.1
If that version is less than 4.6.1, then you still have old version installed, and needs to be updated.
You might need to add more information about your project, deps, etc and maybe even try out to make minimal working example which you can share, where problem occurs.
@kerbe I'm using 4.6.1. Most updated versions of expo, amplify cli and etc.
The changes from #8162 were published late last week and are expected to resolve this.
@vahdet, can you confirm whether this resolves your issue?
@EvanErickson, have you tried clobbering your node_modules
? Are you also on the latest version of aws-amplify
?
@svidgen With my latest environment as shown in details
section below, I could sign in. So, no problem for my case now:
A quick note: merely running expo start
command already emits the following which was the message I previously seen only after applying EXPO_LEGACY_IMPORTS=1
:
Dangerously enabled the deprecated `.expo` extensions feature, this functionality may be removed between SDK cycles.
I ended up making a whole new project, whole new expo init, whole new amplify init, etc. I then copied and pasted my code into the new one and it works.
On Mon, May 10, 2021 at 2:39 PM vahdet @.***> wrote:
With my latest environment as shown in details section below, I could be able to sign in:
System: OS: Windows 10 10.0.19042 CPU: (8) x64 Intel(R) Core(TM) i5-10310U CPU @ 1.70GHz Memory: 752.43 MB / 7.77 GB Binaries: Node: 14.15.3 - C:\Program Files\nodejs\node.EXE Yarn: 1.22.10 - ~\AppData\Roaming\npm\yarn.CMD npm: 6.14.9 - C:\Program Files\nodejs\npm.CMD Browsers: Edge: Spartan (44.19041.906.0), Chromium (90.0.818.56) Internet Explorer: 11.0.19041.1 npmPackages: @aws-amplify/api: ^3.3.0 => 3.3.0 @aws-amplify/auth: ^3.4.31 => 3.4.31 @aws-amplify/pubsub: ^3.3.0 => 3.3.0 @aws-amplify/storage: ^3.4.1 => 3.4.1 @babel/core: ~7.9.0 => 7.9.0 @babel/preset-typescript: ^7.13.0 => 7.13.0 (7.12.17) @react-native-async-storage/async-storage: ^1.13.0 => 1.15.4 @react-native-community/datetimepicker: 3.2.0 => 3.2.0 @react-native-community/eslint-config: ^2.0.0 => 1.1.0 (2.0.0) @react-native-community/eslint-plugin: 1.0.0 @react-native-community/masked-view: 0.1.10 => 0.1.10 @react-native-community/netinfo: 6.0.0 => 6.0.0 @react-native-community/segmented-control: ^2.2.2 => 2.2.2 @react-navigation/bottom-tabs: ^5.10.1 => 5.11.10 @react-navigation/native: ^5.8.1 => 5.9.4 @react-navigation/stack: ^5.11.0 => 5.14.4 @types/i18n-js: ^3.0.3 => 3.8.0 @types/jest: ^26.0.15 => 26.0.23 @types/react: ~16.9.35 => 16.9.56 (17.0.5) @types/react-native: ~0.63.2 => 0.63.52 (0.64.4) @types/react-test-renderer: ^17.0.0 => 17.0.1 @types/yup: ^0.29.9 => 0.29.11 @typescript-eslint/eslint-plugin: ^4.14.0 => 4.22.1 (3.10.1) @typescript-eslint/parser: ^4.14.0 => 4.22.1 (3.10.1) HelloWorld: 0.0.1 babel-plugin-inline-dotenv: ^1.6.0 => 1.6.0 babel-plugin-inline-view-configs: 0.0.5 babel-plugin-module-resolver: ^4.0.0 => 4.1.0 (3.2.0) checkbox: 0.0.1 eslint: ^7.17.0 => 7.25.0 eslint-plugin-jsx-a11y: ^6.4.1 => 6.4.1 eslint-plugin-prettier: ^3.1.4 => 3.4.0 (3.1.2) expo: ^41.0.0 => 41.0.1 expo-cellular: ~3.1.0 => 3.1.0 expo-constants: ~10.1.3 => 10.1.3 expo-image-picker: ~10.1.4 => 10.1.4 expo-localization: ~10.1.0 => 10.1.0 expo-location: ~12.0.4 => 12.0.4 expo-status-bar: ~1.0.4 => 1.0.4 formik: ^2.2.6 => 2.2.6 hermes-inspector-msggen: 1.0.0 husky: ^6.0.0 => 6.0.0 i18n-js: ^3.8.0 => 3.8.0 jest-expo: ^41.0.0 => 41.0.0 lottie-react-native: 3.5.0 => 3.5.0 prettier: ^2.1.2 => 2.2.1 react: 16.13.1 => 16.13.1 react-animated: 0.1.0 react-async-hook: ^3.6.2 => 3.6.2 react-dom: 16.13.1 => 16.13.1 react-native: https://github.com/expo/react-native/archive/sdk-41.0.0.tar.gz => 0.63.2 react-native-appearance: ~0.3.3 => 0.3.4 react-native-bouncy-checkbox: ^2.0.0 => 2.1.0 react-native-codegen: 0.0.2 react-native-elements: ^3.1.0 => 3.4.1 react-native-gesture-handler: ~1.10.2 => 1.10.3 react-native-maps: 0.27.1 => 0.27.1 react-native-reanimated: ~2.1.0 => 2.1.0 react-native-safe-area-context: 3.2.0 => 3.2.0 react-native-screens: ~3.0.0 => 3.0.0 react-native-skeleton-placeholder: ^3.0.4 => 3.0.4 react-native-web: ^0.16.2 => 0.16.2 react-test-renderer: ^17.0.1 => 17.0.2 (16.11.0) typescript: ~4.0.0 => 4.0.7 yup: ^0.32.8 => 0.32.9 npmGlobalPackages: @aws-amplify/cli: 4.50.2 appium: 1.20.2 aws-cdk: 1.91.0 expo-cli: 4.4.4 yarn: 1.22.10
A quick note: merely running expo start command already emits the following which was the message I previously seen only after applying EXPO_LEGACY_IMPORTS=1:
Dangerously enabled the deprecated
.expo
extensions feature, this functionality may be removed between SDK cycles.— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/aws-amplify/amplify-js/issues/8113#issuecomment-837387911, or unsubscribe https://github.com/notifications/unsubscribe-auth/AICKE4VMXMVKJGQC4MFY6ADTNBHATANCNFSM43DNCEJA .
-- Evan Scott Erickson @.***
Gotcha, @EvanErickson. Sorry it had get nuclear, but I'm glad it's working!
@vahdet, is there any possibility you have a loitering environment variable? To the best of my recollection, I have not encountered this error message apart from setting that legacy imports flag.
@svidgen Oh yes. did not mean it but reading again that particular info I have given might sound confusing. The warning is not necessarily stemming from Amplify lib.
It is ok for me if the issue is closed.
Sounds good. Thank-you!
Upgrading aws-amplify@3.3.11
to aws-amplify@4.0.2
worked for me.
This happened to be after upgrading from Expo SDK 40 to 42.
Solution was to upgrade all the amplify libraries.
This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.
Looking for a help forum? We recommend joining the Amplify Community Discord server *-help
channels or Discussions for those types of questions.
Before opening, please confirm:
JavaScript Framework
React Native
Amplify APIs
Authentication
Amplify Categories
auth
Environment information
Describe the bug
Auth.signIn
throws an exception:Expected behavior
A successful sign in
Reproduction steps
Try
await Auth.signIn(...)
, otherwise the source code of my project can be checked (specifically at line: https://github.com/gimmickless/iyiye-native-app/blob/121af2c64aaecac02a6e9cd759f28182908ee0ed/src/contexts/Auth.tsx#L224)Code Snippet
Log output
aws-exports.js
No response
Manual configuration
Additional configuration
No response
Mobile Device
Samsung Galaxy A51
Mobile Operating System
Android11
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response