question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Auth.signIn() promise takes more than 30 seconds to resolve on Android

See original GitHub issue

Describe 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:

  1. Close all apps on device.
  2. Start React Native app using npx react-native run-android
  3. Click on “Login”
  4. 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 Bildschirmfoto 2020-04-24 um 15 23 45 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",
    

}; };

**Smartphone (please complete the following information):**

- Device: We can see it in all kinds of Android Devices


Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:2
  • Comments:52 (13 by maintainers)

github_iconTop GitHub Comments

2reactions
IanPhilipscommented, May 3, 2021

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 my babel.config.js to the basic module.exports = { presets: ['@expo/next-adapter/babel']}; and then starting expo cleanly via expo start -c the amplify sign in method now works like a charm on both OS’s!

2reactions
jamesalestercommented, Nov 25, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to wait for FirebaseAuth to finish initializing?
Exiting the app and launching it again solves the problem (app no longer asks the user to sign in again), though it provides...
Read more >
Authenticate with Firebase on Android using a Phone Number
You can use Firebase Authentication to sign in a user by sending an SMS message to the user's phone. The user signs in...
Read more >
Changing Async/Await to Promises.allSettled() to Speed Up ...
Updating one record makes an API call that takes 500ms to 1s. And since it iterates over the records and updates them one...
Read more >
Resolve promise after given amount of time
Use the Promise constructor to create a new promise. Use setTimeout() to call the promise's resolve function with the passed value after the ......
Read more >
Top 10 Most Common Node.js Developer Mistakes - Toptal
Node.js, the cross-platform runtime environment, has seen its fair share of praise and criticism for what it offers to developers.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found