Auth.signIn() promise takes more than 30 seconds to resolve on Android
See original GitHub issueDescribe the bug Auth.signIn() promise can take more than 30 seconds to resolve on Android. On iOS and Web we could not reproduce the bug. It happens when we start the app and we click “Login” for the first time. It doesn’t always happen, we have to try a few times to reproduce it.
To Reproduce Steps to reproduce the behavior:
- Close all apps on device.
- Start React Native app using npx react-native run-android
- Click on “Login”
- See console to see how many miliseconds it took to complete the authentication.
Expected behavior It should always be complete under 3 seconds as it happens on the other platforms.
Code Snippet
App.tsx :
import React from “react”; import { StyleSheet, Text, View, TouchableOpacity } from “react-native”; import Amplify, { Auth } from “aws-amplify”; import {awsmobileDev} from ‘./aws-exports’ Amplify.configure(awsmobileDev);
export default class App extends React.Component<{}, {}> { render() { return ( <View style={styles.container}> <TouchableOpacity style={{ height: 50, width: 200 }} onPress={async () => { console.log(“Signing in…”); const timeStart = new Date().getTime(); await Auth.signIn(“username”, “password”); const timeEnd = new Date().getTime(); console.log("Sign in successfull. ", timeEnd - timeStart); }} > <Text>Login</Text> </TouchableOpacity> </View> ); } }
const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: “#fff”, alignItems: “center”, justifyContent: “center”, }, });
Screenshots Here for example, it lasted 128 seconds to login!
What is Configured? If applicable, please provide what is configured for Amplify CLI:
- Which steps did you follow via Amplify CLI when configuring your resources.
- Which resources do you have configured?
- If applicable, please provide your
aws-exports
file:
const awsmobile = { aws_project_region: "eu-central-1", aws_cognito_identity_pool_id: "eu-central-1:xxx", aws_cognito_region: "eu-central-1", aws_user_pools_id: "eu-central-1_xxx", aws_user_pools_web_client_id: "xxx", oauth: {}, aws_appsync_graphqlEndpoint: "https://xxx.appsync-api.eu-central-1.amazonaws.com/graphql", aws_appsync_region: "eu-central-1", aws_appsync_authenticationType: "AMAZON_COGNITO_USER_POOLS", aws_cloud_logic_custom: [ { name: "xxx", endpoint: "https://xxx.execute-api.eu-central-1.amazonaws.com/dev", region: "eu-central-1", }, ], aws_mobile_analytics_app_id: "xxx", aws_mobile_analytics_app_region: "eu-central-1", aws_user_files_s3_bucket: "xxx-dev", aws_user_files_s3_bucket_region: "eu-central-1",
- If applicable, please provide your
}; };
**Smartphone (please complete the following information):**
- Device: We can see it in all kinds of Android Devices
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:52 (13 by maintainers)
Top GitHub Comments
I was having this issue after developing out my web version for a while and started testing on my mobile builds. I found my android build was working and navigating fine but amplify’s
signIn()
method was taking forever. I went to check and see what was going on with my iOS build and it wouldn’t navigate from my root view. It was throwing this error. Upon resetting mybabel.config.js
to the basicmodule.exports = { presets: ['@expo/next-adapter/babel']};
and then starting expo cleanly viaexpo start -c
the amplify sign in method now works like a charm on both OS’s!So after a few days of debugging and going through all of the issues on the react native Github related to fetches on Android I found a solution that works for my problem… disconnecting the wifi on the emulator and reconnecting! 😑
My colleague was getting the same problem that I was so it could be a bug in the android emulator so if anyone is getting the same issue give that a try first.
It doesn’t look like an issue with amplify, at least for me.